How can I get the data and sectioned by month from a range of dates in MYsql?

0

I have a problem, I have a series of data that I must obtain but these I must section by month, for example I have 5 items that were sold in May, and 10 in the month of April, but this must be sectioned for months according to the date specified by the user.

    
asked by Jonathan Rodriguez Hernandez 22.05.2018 в 06:31
source

1 answer

0

I think this will help you to make your inquiry.

SELECT year(arti_fecha) as anio, month(arti_fecha) as mes, count(*)  as cant
FROM articulos
GROUP BY  year(arti_fecha), month(arti_fecha)

Result of the query:

| anio | mes | cant |
  2018    2       43
  2018    3       13
  2018    4       84
  2018    5       79

You could add the WHERE statement if you want to filter it by some client, branch or vendor

    
answered by 25.05.2018 в 22:01