sql中case when的小學

wisdomone1發表於2012-10-11
SQL> select * from t_test_12;
 
                                 TYPEID TYPENAME
--------------------------------------- --------------------------------------------------------------------------------
                                      1 zxy1
                                      2 zxy2
 
 
SQL> select (case when typeid=1 then (select 'zxy1' from dual)
  2               when typeid=2 then (select 'zxy2' from dual)
  3          end)
  4  from t_test_12
  5  /
 
(CASEWHENTYPEID=1THEN(SELECT'Z
------------------------------
zxy1
zxy2
 
 
小結:1,case when ,when可以是複雜的sql組合,then也可以是複雜的sql組合

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-746205/,如需轉載,請註明出處,否則將追究法律責任。

相關文章