Return date quantity in Mysql

Asked

Viewed 21 times

0

I have the table containing the date field.

| Data|
| 2016-06-09   |
| 2016-06-09   |
| 2016-06-09   |
| 2016-06-08   |
| 2016-06-08   |
| 2016-06-05   |
| 2016-06-01   |

I want you to come back more or less like this:

| Data | Quantidade |
| 2016-06-09 | 3 |
| 2016-06-08 | 2 |
| 2016-06-05 | 1 |
| 2016-06-01 | 1 |

1 answer

3


Use the COUNT and the GROUP BY:

SELECT `Data`, COUNT(`Data`) AS 'Quantidade' FROM sua_tabela
GROUP BY `Data`;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.