Answers for "mysql count by month"

SQL
0

mysql count by month

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 |
|              ... |               ... |       ... |
+------------------+-------------------+-----------+
Posted by: Guest on September-02-2021

Code answers related to "SQL"

Browse Popular Code Answers by Language