私の選択:
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
私の例に対して同じ応答を表示するにはどうすればよいですか?
ありがとう!!