0
I have the following appointment:
SELECT
numero,
sistema,
status,
date_first_queued
FROM
ocorrencias
HAVING DATE(date_first_queued) between DATE_FORMAT(CURDATE() ,'%Y-%m-01') AND CURDATE()
AND sistema = '17'
She returns me the records perfectly, but I want to use together with her a count
only then it returns empty, follows my query with count
:
SELECT
COUNT(numero),
numero,
sistema,
status,
date_first_queued
FROM
ocorrencias
HAVING DATE(date_first_queued) between DATE_FORMAT(CURDATE() ,'%Y-%m-01') AND CURDATE()
AND sistema = '17'
I even need to use the group by
more when I put the group by
of the following error below:
Count always returns a row, not several rows. With this thought I don’t understand why I want the remaining columns. GROUP BY should come before order by if you want order by should first do a subquery.
– Tiago Gomes
To be easier you can put an example for example http://sqlfiddle.com/ to have data to manipulate.
– Tiago Gomes
Here it is: http://sqlfiddle.com/#! 9/ec6a9/1
– Chefe Druida