类似于ORACLE decode 的用法

SQL Server 2008中的写法:
select t.PROJECTNAME, t.BUILDCONTENTSCALE,  CASE t.PROJECTLEVEL      WHEN '0' THEN '国家重点'      WHEN '1' THEN '省重点'      WHEN '2' THEN '市重点'      WHEN '3' THEN '区/县重点'      END AS PROJECTLEVEL, t.TOTALINVESTMENT, t.PROGRESSCONTENT, t.BUILDCOMPANY,  t.CONTACTWAY, t.DUTYDEPT, t.REMARK from t_iipms_applayprojects t  where t.projecttype = '1'   and t.isvoided = '0';
Oracle 10g中的写法:
select t.PROJECTNAME,       t.BUILDCONTENTSCALE,       decode(t.PROJECTLEVEL,              '0',              '国家重点',              '1',              '省重点',              '2',              '市重点',              '3',              '区/县重点') as PROJECTLEVEL,       t.TOTALINVESTMENT,       t.PROGRESSCONTENT,       t.BUILDCOMPANY,       t.CONTACTWAY,       t.DUTYDEPT,       t.REMARK  from t_iipms_applayprojects t where t.projecttype = '1'   and t.isvoided = '0';
细节对比看效果很明显:SQL Server 2008中
CASE t.PROJECTLEVEL      WHEN '0' THEN '国家重点'      WHEN '1' THEN '省重点'      WHEN '2' THEN '市重点'      WHEN '3' THEN '区/县重点'      END AS PROJECTLEVELOracle 10g中decode(t.PROJECTLEVEL,              '0',              '国家重点',              '1',              '省重点',              '2',              '市重点',              '3',              '区/县重点') as PROJECTLEVEL
---------------------
作者:长安散人
来源:CSDN
原文:https://blog.csdn.net/hu_shengyang/article/details/10533865
版权声明:本文为博主原创文章,转载请附上博文链接!
posted @ 2019-05-15 22:55  厦门哈韩  阅读(610)  评论(0编辑  收藏  举报