0
I have the following table
+----------+----------+
| data | valor |
+----------+----------+
| 16/05/15 | 1 |
| 16/05/15 | 0 |
| 16/05/15 | 1 |
| 16/05/15 | 0 |
| 17/05/15 | 2 |
| 17/05/15 | 1 |
| 17/05/15 | 1 |
| 17/05/15 | 0 |
| 18/05/15 | 2 |
| 18/05/15 | 2 |
| 18/05/15 | 1 |
| 18/05/15 | 0 |
| 19/05/15 | 2 |
| 19/05/15 | 2 |
| 19/05/15 | 2 |
| 19/05/15 | 2 |
+----------+----------+
I need to make an sql that counts the amount of 0, 1 and 2, but I am only able to do with separate sql, how can I make a single select?
SELECT data, COUNT(valor)
FROM treatment_output
WHERE valor = 0
GROUP BY data ORDER BY data
Do you want to count the amount of these 3 numbers (value) ? are only these ? is separated by Date ? or goes if one column for each?
– Marco Souza
Dude, Voce was so close... SELECT data, COUNT(value) FROM treatment_output -WHERE value = 0 GROUP BY data,value ORDER BY data
– Ricardo da Rocha Vitor
why the "Conditional"?
– Andre Figueiredo
I need value=0, 1 and 2 to be counted and create new columns for each of them.
– spiderman123