mysql count by month

Solutions on MaxInterview for mysql count by month by the best coders in the world

showing results for - "mysql count by month"
Albie
11 Mar 2017
1select year(order_date),month(order_date),count(*)
2     from sales
3     group by year(order_date),month(order_date)
4     order by year(order_date),month(order_date);
5+------------------+-------------------+-----------+
6| year(order_date) | month(order_date) | count(*) |
7+------------------+-------------------+-----------+
8|             2020 |                 1 |       408 |
9|             2020 |                 2 |       320 |
10|             2020 |                 3 |       540 |
11|              ... |               ... |       ... |
12+------------------+-------------------+-----------+