ITeye博客

decode与case when比较

xiajava2011 · 2011-08-19 10:11 · oracle数据库 · 数据库 · Markdown

decode只能做等值的,case when可以做区间的,decode能做到的,case when也能做到。

效率方面,个人觉得两者效率差不多。

但decode的语法要简单些,但它只能做等值的比较

case when end 能做条件的判断

select case when b.total_fee is null then 0 else b.total_fee end from t_pm_billing_stat b 
select a.area_name, decode(b.billing_amount,null,0 ,b.billing_amount) from t_pm_billing_stat b 

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。