SQL模糊匹配後再分組

####按硬件廠家統計覆蓋質量
create table Manufacture_STAT
(select 
(case 
    when DeviceId like '%CIOT%' then 'CIOT'
when DeviceId like '%FHTT%' then 'FHTT'
when DeviceId like '%HWTC%' then 'HWTC'
when DeviceId like '%NBEL%' then 'NBEL'
    else 'Other' end) as Manufa,
count(*) as AllNum,
sum(case when SubdeviceWlanRadioPower >= -67 then 1 else 0 end) as GoodNum,
sum(case when SubdeviceWlanRadioPower <= -68 and SubdeviceWlanRadioPower >= -70 then 1 else 0 end ) as NormalNum,
sum(case when SubdeviceWlanRadioPower <= -71 then 1 else 0 end) as PoorNum
from wide_table_all_row
where SubdeviceWlanRadioPower!= ''
group by 
(case 
        when DeviceId like '%CIOT%' then 'CIOT'
when DeviceId like '%FHTT%' then 'FHTT'
when DeviceId like '%HWTC%' then 'HWTC'
when DeviceId like '%NBEL%' then 'NBEL'
    else 'Other' end));
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章