Search
 
SCRIPT & CODE EXAMPLE
 

SQL

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 |
|              ... |               ... |       ... |
+------------------+-------------------+-----------+
Comment

PREVIOUS NEXT
Code Example
Sql :: query by column for substring sql 
Sql :: default number in sql 
Sql :: mysql delete data in table 
Sql :: installing mysql on centos 7 
Sql :: restart serial number for postgres 
Sql :: get yesterday date ISO in psql 
Sql :: oracle duration between timestamps 
Sql :: mysql auerries to find the name starting with vowel letter 
Sql :: drop CHECK constraint sql 
Sql :: sql database connectivity 
Sql :: login phpmyadmin without password 
Sql :: drop schema sql 
Sql :: sql stored procedure update if parameter is not null 
Sql :: select random rows sql 
Sql :: charindex 
Sql :: date sql 
Sql :: create table like another table 
Sql :: declare table variable sql 
Sql :: function in postgresql 
Sql :: clear table sql 
Sql :: postgres data location 
Sql :: eliminar ultimo carcacter mysql 
Sql :: import data from csv to sql server 
Sql :: mysql remove unique key 
Sql :: mysql if statement 
Sql :: sql delete 
Sql :: ms sql print more than 1 variable 
Sql :: SQL Error [42501]: ERROR: permission denied for table 
Sql :: sql rename table 
Sql :: insert into sql 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =