乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      Decode 函數(shù)的用法

       執(zhí)著男孩 2006-09-09
      Decode 函數(shù)的用法
      作者:無從考證  來源:轉(zhuǎn)載  發(fā)布時(shí)間:2005-9-21 16:23:18  發(fā)布人:admin

      8){NewaspContentLabel.style.fontSize=(--newasp_fontsize)+"pt";NewaspContentLabel.style.lineHeight=(--newasp_lineheight)+"pt";}‘>減小字體 增大字體

            在數(shù)據(jù)庫開發(fā)的過程當(dāng)中,有很多時(shí)候需要將行轉(zhuǎn)換成列或者將列轉(zhuǎn)換成行來顯示數(shù)據(jù),而往往我們?cè)诮⒈斫Y(jié)構(gòu)時(shí)不能根據(jù)顯示的要求來保存數(shù)據(jù),于是乎只能在保存數(shù)據(jù)之后做一些必要的操作(比方說:建立視圖等)來達(dá)到顯示的目的。   
             下面用一個(gè)常見的數(shù)據(jù)顯示來說明decode函數(shù)的用法。就是成績單的顯示,這個(gè)是教學(xué)管理系統(tǒng)中最常見的。我想做開發(fā)的人員都遇到過這個(gè),而且在大學(xué)期間也是常常接觸成績單,顯示的是:姓名、語文、數(shù)學(xué)等  
              實(shí)現(xiàn)腳本如下(cjd.sql):  
      --建表  
      create table stud  
      (  
       sid  varchar2(10),  
       kcbm  varchar2(10),  
       cj  int  
      );  
      --插入測試數(shù)據(jù)  
      insert into stud values(’1’,’語文’,80);  
      insert into stud values(’2’,’數(shù)學(xué)’,90);  
      insert into stud values(’3’,’英語’,100);  
      commit;  
      --創(chuàng)建視圖,decode用法  
      create or replace view cjd as  
       select sid,  
       decode(kcbm,’語文’,cj,0) 語文,  
       decode(kcbm,’數(shù)學(xué)’,cj,0) 數(shù)學(xué),  
       decode(kcbm,’英語’,cj,0) 英語  
       from stud  
       order by sid;  
      --顯示數(shù)據(jù)  
      select * from cjd;  
      執(zhí)行過程如下:  
      SQL> create table stud(sid varchar2(10),  
        2  kcbm varchar2(10),  
        3  cj int);  
      表已創(chuàng)建。  
      SQL> insert into stud values(’1’,’語文’,80);  
      已創(chuàng)建 1 行。  
      SQL> insert into stud values(’2’,’數(shù)學(xué)’,90);  
      已創(chuàng)建 1 行。  
      SQL> insert into stud values(’3’,’英語’,100);  
      已創(chuàng)建 1 行。  
      SQL> commit;  
      提交完成。  
      SQL> create or replace view cjd as  
        2  select sid,  
        3  decode(kcbm,’語文’,cj,0) 語文,  
        4  decode(kcbm,’數(shù)學(xué)’,cj,0) 數(shù)學(xué),  
        5  decode(kcbm,’英語’,cj,0) 英語  
        6  from stud  
        7  order by sid;  
      視圖已建立。  

      SQL> select * from cjd;   

      SID           語文       數(shù)學(xué)       英語                                    
      ---------- ---------- ---------- ----------                                    
      1            80          0           0                                    
      2            0           90          0                                    
      3            0           0           100        

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多