一个表中一次性分类返回满足不同条件的数据

来源:互联网 发布:天数倒计时软件 编辑:程序博客网 时间:2024/05/21 12:46

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

ibatis查询SQL语句返回一个对象,此对象包含一个List属性

0 0