select sum(case a.proc_stat when 'E' then 1 else 0 end)
from cpnst_appl a
where a.cpnst_caserpt_id in
……
现在想把when 'E' 写成一个范围的形式
如proc_stat 在20080101到20080909之间的 该怎么写
when between?
...全文
666打赏收藏
sql语句中case的写法问题
select sum(case a.proc_stat when 'E' then 1 else 0 end) from cpnst_appl a where a.cpnst_caserpt_id in …… 现在想把when 'E' 写成一个范围的形式 如proc_stat 在20080101到20080909之间的 该怎么写 when between?
select sum(case when a.proc_stat between to_date('20080101','yyyymmdd') and to_date('20080909','yyyymmdd') then 1 else 0 end)
from cpnst_appl a
where a.cpnst_caserpt_id in
select sum(case when a.proc_stat between to_date('20080101','yyyymmdd') and to_date('20080909','yyyymmdd') then 1 else 0 end)
from cpnst_appl a
where a.cpnst_caserpt_id in
……