Make monthly report of sql data

1

How can I get monthly data for example from day 1 to 1 or if it is in the current month from day 1 to the current one.

Having a table such that:

+---------------------------------------+
|  id  |  estado   |         fecha      |
+------+-----------+--------------------+
|  1   |    10     | 2017-02-13 9:30:00 |
|  2   |    10     | 2017-02-13 9:30:00 |
|  3   |    10     | 2017-02-14 9:30:00 |
|  4   |    10     | 2017-02-15 9:30:00 |
|  5   |    10     | 2017-02-15 9:30:00 |
|  6   |    10     | 2017-02-15 9:30:00 |
|  7   |    10     | 2017-02-16 9:30:00 |
+---------------------------------------+

I want to take out for each day how many states of each are changed. For example, on the 13th there are 2, on the 14 there are 1, on the 15 there are 3, on the 16 there is 1, how can I get that data, especially important that it be monthly from day 1 to day 1 ..

Thanks

    
asked by Pavlo B. 13.02.2017 в 09:37
source

1 answer

1

Select the COUNT(estado) and group it by day using the DAY function:

SELECT DAY(fecha), COUNT(estado) FROM Table_Name GROUP BY DAY(fecha);
    
answered by 13.02.2017 / 10:17
source