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);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章