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?

解决方案 »

  1.   

    why not set the criteria in the where clause directly?
    a.proc_stat between(1, 2)?
      

  2.   

    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 
    …… 应该可以的~~~
      

  3.   

    不是放在where里作为条件的,楼上的我试试
      

  4.   

    case when **** then ** when **** then ** else * end**** 就是条件表达式,你between and 或者别的什么都可以的啦
      

  5.   

    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