📜  mysql 按月计数 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:09.079000             🧑  作者: Mango

代码示例1
select year(order_date),month(order_date),count(*)
     from sales
     group by year(order_date),month(order_date)
     order by year(order_date),month(order_date);
+------------------+-------------------+-----------+
| year(order_date) | month(order_date) | count(*) |
+------------------+-------------------+-----------+
|             2020 |                 1 |       408 |
|             2020 |                 2 |       320 |
|             2020 |                 3 |       540 |
|              ... |               ... |       ... |
+------------------+-------------------+-----------+