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 查询多个条件的多个数量
最新推荐文章于 2024-01-02 17:45:06 发布