SQL 先分组再分段统计每段个数

####按家庭维度统计信号强度
create table Power_STAT
(select 
DeviceId,
count(DeviceId) 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 DeviceId);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章