,我使用MySQL表的排序更具有結構:MySQL查詢結果爲
id | type | date
--------------------------------
101 | 1 | 2011-02-08
102 | 2 | 2011-02-08
103 | 2 | 2011-02-08
104 | 2 | 2011-02-07
105 | 1 | 2011-02-07
105 | 1 | 2011-02-07
我想要做的就是創建一個查詢,將給出以下結果:
total type 1 | total type 2 | date
------------------------------------------------
1 | 2 | 2011-02-08
2 | 1 | 2011-02-07
我試着用下面的查詢,但沒有得到期望的結果
SELECT count(DISTINCT id) as total, date, type FROM my_table WHERE type !='0' GROUP BY date, type ORDER BY date DESC
我怎麼能這樣做? 感謝所有建議
謝謝。這是正確的查詢。 – Sergio 2011-02-08 21:51:24