我有这个查询:
SELECT YEAR(datetime) AS Year, WEEK(datetime) AS Week, COUNT(*) AS total
FROM table
GROUP BY Year, Week;
结果是:
+------+------+-------+
| Year | Week | total |
+------+------+-------+
| 2016 | 49 | 14 |
| 2016 | 50 | 20 |
| 2016 | 51 | 19 |
| 2016 | 52 | 15 |
| 2017 | 1 | 13 |
| 2017 | 2 | 14 |
| 2017 | 3 | 12 |
| 2017 | 4 | 12 |
| 2017 | 5 | 5
但我想知道如何以“更美丽”的方式展示这一周,例如:
+------+----------+-------+
| Year | Week | total |
+------+----------+-------+
| 2016 | Dec 05 | 14 |
| 2016 | Dec 12 | 20 |
| 2016 | Dec 19 | 19 |
| 2016 | Dec 26 | 15 |
| 2017 | Jan 02 | 13 |
| 2017 | Jan 09 | 14 |
| 2017 | Jan 16 | 12 |
| 2017 | Jan 23 | 12 |
| 2017 | Jan 30 | 5 |
+------+----------+-------+