我的选择:
SELECT DISTINCT
(SELECT COUNT(*)
FROM t_table
WHERE year(date) BETWEEN '2013' AND '2013' AND month(date) BETWEEN '1' AND '12' AND date!=cad_em) as total1,
(SELECT COUNT(*)
FROM t_table
WHERE year(date) BETWEEN '2013' AND '2013' AND month(date) BETWEEN '1' AND '12' AND date=cad_em ) as total2
FROM t_table
GROUP BY date
返回:
total1 | total2
1 4
但我想返回日期示例:
date | total1 | total2
2013-10 7 8
2013-11 1 4
2013-12 2 5
我怎样才能对我的例子做出同样的反应?
谢谢!!