oracle数据库中的decode何case when

decode是oracle特有的,case when是所有关系型数据库都可以提供的、

  其实他们都是为了实现判断逻辑

    代表if  else  只不过decode的写法更加的简介而已,decode能实现的case when都可以实现

select t.accname,t.sendstandard, decode(retiretype,'2',t.sendstandard) as"语文" , decode(retiretype,'1',t.sendstandard) as"数学" from    LCAnnualGet t  where rownum<100



select t.accname,t.sendstandard, case when  t.retiretype='2' then t.sendstandard  end as "语文", case when t.retiretype='1' then t.sendstandard  end as"数学" from    LCAnnualGet t  where rownum<100

猜你喜欢

转载自blog.csdn.net/xuedengyong/article/details/79384950