select project_no,
sum(case when device_state=0 then 1 else 0 end)as offTotal ,
sum(case when device_state=1 then 1 else 0 end)as onlineTotal,
sum(1)total
from iot_d_device
group by project_no
order by project_no
mySql关于统计数量的SQL查询
猜你喜欢
转载自blog.csdn.net/megamind_hl/article/details/80512331
今日推荐
周排行