select distinct h.device_id,
(select count(*) from print_task_hist a where a.device_id = h.device_id where…(条件一)… ) as yesterDayTotal,
(select count(*) from print_task_hist a where a.device_id = h.device_id where…(条件二)… ) as currentMonthTotal,
(select count(*) from print_task_hist a where a.device_id = h.device_id where…(条件三)… ) as previousMonthTotal
from print_task_hist h;
SELECT w.wx_original_id AS “wxOriginalId”,
(SELECT count(*) as total FROM print_task_hist a where a.wx_original_id = w.wx_original_id) AS “yesterDayTotal”
FROM
(SELECT DISTINCT wx_original_id FROM print_task_hist WHERE device_id = ‘7vt4hnou2a’) w
本文介绍了一种使用SQL查询来统计特定设备ID及微信原始ID的任务历史记录数量的方法。通过多个子查询,分别计算了昨日总数、当月总数及上月总数等关键指标。
5万+

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



