使用Case语句如何得到下面的结果
在Oracle中执行下面的语句:
select case
when Ratedn_Max<1024 then '<1M'
when Ratedn_Max>=1024 and Ratedn_Max<2048 then '1M-2M'
when Ratedn_Max>=2048 and Ratedn_Max<3072 then '2M-3M'
when Ratedn_Max>=3072 and Ratedn_Max<4096 then '3M-4M'
when Ratedn_Max>=4096 and Ratedn_Max<5120 then '4M-5M'
when Ratedn_Max>=5120 and Ratedn_Max<6144 then '5M-6M'
when Ratedn_Max>=6144 and Ratedn_Max<7168 then '6M-7M'
when Ratedn_Max>=7168 then '>7M'
end maxrate
, count(Ratedn_Max) as line_count
from ccatstep_tbl_montst_statisc a,CCATSTEP_TBL_REP_ENDOFFICE b
where a.office_id = '001' and trunk_id = '003-49Z' and cabinet_id = '01003-043J'
group by case
when Ratedn_Max<1024 then '<1M'
when Ratedn_Max>=1024 and Ratedn_Max<2048 then '1M-2M'
when Ratedn_Max>=2048 and Ratedn_Max<3072 then '2M-3M'
when Ratedn_Max>=3072 and Ratedn_Max<4096 then '3M-4M'
when Ratedn_Max>=4096 and Ratedn_Max<5120 then '4M-5M'
when Ratedn_Max>=5120 and Ratedn_Max<6144 then '5M-6M'
when Ratedn_Max>=6144 and Ratedn_Max<7168 then '6M-7M'
when Ratedn_Max>=7168 then '>7M' end
得到结果:
MAXRATE LINE_COUNT
1M-2M 28
2M-3M 168
5M-6M 7
6M-7M 7
>7M 63
我想得到如果LINE_COUNT是0的也要显示出来,这个如何实现?
既需要得到新的结果:
MAXRATE LINE_COUNT
1M-2M 28
2M-3M 168
3M-4M 0
5M-6M 7
6M-7M 7
>7M 63
请高手帮忙看看。