SELECT
COUNT(*) AS total,
COUNT(case when device_state = '1' then device_state else null end) as totalBeiyong,
COUNT(case when device_state = '2' then device_state else null end) as totalTingyong,
COUNT(case when device_state = '3' then device_state else null end) as totalTingji,
COUNT(case when device_state = '4' then device_state else null end) as totalZhengchang,
COUNT(case when device_state = '5' then device_state else null end) as totalDaibing
FROM
s_equipment
sql 查询多个条件的多个数量
最新推荐文章于 2026-04-18 03:03:28 发布
本文通过SQL查询,汇总了s_equipment表中各设备状态(1-5)的数量,分别展示了总数量及各状态(闲置、使用、测试、正常、待命)的分布,提供了设备活跃度洞察。

1377

被折叠的 条评论
为什么被折叠?



