1
I have this query that returns me the amount of equal dates:
SELECT `Data`, COUNT(`Data`) AS 'Quantidade' FROM sua_tabela GROUP BY `Data`;
| Data | | 2016-06-09 | | 2016-06-09 | | 2016-06-09 | | 2016-06-08 | | 2016-06-08 | | 2016-06-05 | | 2016-06-01 |
Returns like this:
| Data | Quantidade | | 2016-06-09 | 3 | | 2016-06-08 | 2 | | 2016-06-05 | 1 | | 2016-06-01 | 1 |
I would then like to add the Quantity returned for this month
I tried this way:
SELECT Data_reg, SUM(COUNT(Data_reg)) AS 'Soma_total'
FROM Monit
WHERE Data_reg like ('2016-06%')
GROUP BY `Data_reg`;
But returned the following error:
SQL Error (1111): Invalid use of group Function
You want to count only the same dates, or only count ?
– Jeterson Miranda Gomes
In my table there are several other dates, but I would like to add only the month I studied in the example
– Geraldão de Rívia
You’re returning the same error
– Geraldão de Rívia
sorry, I took the date in the wrong place:
SELECT SUM(COUNT(Data_reg)) AS 'Soma_total' FROM Monit WHERE Data_reg like ('2016-06%') group by data_reg;– Jeterson Miranda Gomes
The same error persists :(
– Geraldão de Rívia
SELECT sum(count(data)) qt
 FROM (SELECT '03/01/2018' data FROM DUAL
 UNION ALL
 SELECT '01/01/2018' data FROM DUAL
 UNION ALL
 SELECT '01/01/2018' data FROM DUAL
 UNION ALL
 SELECT '02/01/2018' data FROM DUAL
 UNION ALL
 SELECT '02/01/2018' data FROM DUAL)
 
 GROUP BY datalook at this code I made here, which is exactly the same as yours, runs normally, is sure that the error ofgroup by? (will not run in mysql, as the virtual table created in it is part of oracle functions)– Jeterson Miranda Gomes