我有以下sql:
SELECT count(TableID) AS Counted, Date
FROM Table
WHERE 1
GROUP BY DAY(Date)
问题是,我不希望它每天只被分组一次(1-31)。 我想让它在一年中的每一天之后分组。我希望得到我的回复:
Counted | Date
2 | 2016-11-15
1 | 2016-11-14
3 | 2016-10-15
答案 0 :(得分:1)
SELECT count(TableID) AS Counted, Date
FROM Table
WHERE 1
GROUP BY year(Date), month(Date), day(Date)
答案是答案。感谢@bub。