`

oracle decode case语法

阅读更多
SELECT col1, col2,   
       CASE   
          WHEN col3 > 1 AND col3 <2   
             THEN '1'   
          WHEN col3 > 2 AND col3 <3   
             THEN '2'   
          WHEN col3 > 3 AND col3 <4   
             THEN '3'   
          ELSE '4'   
       END mylevel   
FROM table   
  
select case   
       when    nsrsbh='330165737758262'   then   nsrsbh  
       when    nsrsbh='330106745808709'    then   nsrsbh   
       else     '99999'  
       end   
from WS_TDS_SQ  

select case    nsrsbh
       when   '330165737758262'  then  nsrsbh  
       when   '330106745808709'    then   nsrsbh   
       else    '99999'  
       end   
from table  
  
decode(条件,值1,返回值1,值2,返回值2,...值n,返回值n,缺省值)  
decode(字段或字段的运算,值1,值2,值3)  
select decode (value, <if this value>, <return this value>) FROM table  
  
select decode(col1,'330165737758262',nsrsbh,'330106745808709',nsrsbh,0) from table 
select decode(col1,'330165737758262','6','9') from table  
分享到:
评论

相关推荐

    oracle database 10g 完整参考手册part1

    第16章 DECODE和CASE SQL中的if-then-else 第17章 创建和管理表、视图、索引、群集和序列 第18章 Oracle基本安全 第Ⅲ部分 高级内容 第19章 高级安全性—— 虚拟专用数据库 第20章 使用表空间 第21章 用SQL*Loader...

    Oracle_Database_11g完全参考手册.part2

    原书名: Oracle Database 11g The Complete Reference 原出版社: McGraw-Hill Osborne Media ... 第16章 decode 和case:sql中的if-then-else  第17章 创建和管理表、视图、索引、群集和序列  第18章 分区

    Oracle_Database_11g完全参考手册.part5

    原书名: Oracle Database 11g The Complete Reference 原出版社: McGraw-Hill Osborne Media ... 第16章 decode 和case:sql中的if-then-else  第17章 创建和管理表、视图、索引、群集和序列  第18章 分区

    oracle database 11g 高清完整中文版part2

     第16章 decode 和case:sql中的if-then-else  第17章 创建和管理表、视图、索引、群集和序列  第18章 分区 . 第19章 oracle 基本安全 第ⅲ部分 高 级 主 题  第20章 高级安全性——虚拟专用数据库  第21章 ...

    Oracle_Database_11g完全参考手册.part3

    基本信息 原书名: Oracle Database 11g The Complete Reference 原出版社: McGraw-Hill Osborne ... 第16章 decode 和case:sql中的if-then-else  第17章 创建和管理表、视图、索引、群集和序列  第18章 分区

    Oracle_Database_11g完全参考手册.part4

    原书名: Oracle Database 11g The Complete Reference 原出版社: McGraw-Hill Osborne Media ... 第16章 decode 和case:sql中的if-then-else  第17章 创建和管理表、视图、索引、群集和序列  第18章 分区

    Oracle_Database_11g完全参考手册.part2/3

    第16章 DECODE和CASE.SQL中的if-fhen-else 第17章 创建和管理表、视图、索引、群集和序列 第18章 分区 第19章 Oracle基本安全 第Ⅲ部分 高级主题 第20章 高级安全性-虚拟专用数据库 第21章 高级安全性:透明数据加密...

    Oracle_Database_11g完全参考手册.part3/3

    第16章 DECODE和CASE.SQL中的if-fhen-else 第17章 创建和管理表、视图、索引、群集和序列 第18章 分区 第19章 Oracle基本安全 第Ⅲ部分 高级主题 第20章 高级安全性-虚拟专用数据库 第21章 高级安全性:透明数据加密...

    oracle database 11g 完整参考手册中文高清完整版part3

     第16章 decode 和case:sql中的if-then-else  第17章 创建和管理表、视图、索引、群集和序列  第18章 分区 . 第19章 oracle 基本安全 第ⅲ部分 高 级 主 题  第20章 高级安全性——虚拟专用数据库  第21章 ...

    oracle database 11g完全参考手册 高清完整版part1 共3部分

     第16章 decode 和case:sql中的if-then-else  第17章 创建和管理表、视图、索引、群集和序列  第18章 分区 . 第19章 oracle 基本安全 第ⅲ部分 高 级 主 题  第20章 高级安全性——虚拟专用数据库  第21章 ...

    racle_Database_11g完全参考手册.part1

    原书名: Oracle Database 11g The Complete Reference 原出版社: McGraw-Hill Osborne Media ... 第16章 decode 和case:sql中的if-then-else  第17章 创建和管理表、视图、索引、群集和序列  第18章 分区

    oracle获取上一旬的开始时间和结束时间的实现函数

    代码如下: — 获取上旬开始... select case decode(trunc((to_char(v_rq, ‘dd’) – 1) / 10), 0, ‘上旬’, 1, ‘中旬’, ‘下旬’) when ‘上旬’ then –返回上个月的下旬 to_char(add_months(v_rq, -1), ‘yyyyMM

    Oracle事例

    sql&gt; alter index xay_id allocate extent(size 200k datafile \'c:/oracle/index.dbf\'); &lt;8&gt;.alter index xay_id deallocate unused; 、查看索引 SQL&gt;select index_name,index_type,table_name from user...

    SQL培训第一期

    create tablespace TS_DJY datafile 'd:/software/oracle/tablespace/ts_djy.dat' size 1024M autoextend on next 100M maxsize 2048M; 2.1.1.2 指定用户表空间 alter user cssdj default tablespace TS_DJY; 2.1....

Global site tag (gtag.js) - Google Analytics