Query in mysql grouped by hour

0

Good afternoon. I'm doing a query in mysql and it returns the precise values.

My problem is to display values that do not return eg: I asked to group by hour or by day it only returns values that are data. Since values that do not have data and should return the date with count 0 do not return.

My query is as follows:

select date_format(dt_cad, '%Y-%m-%d') d, date_format(dt_cad, '%d/%m/%Y') d2, count(id_face) c, id_face 
from imagens 
where dt_cad between '2018-11-16' and '2018-11-19 23:59:59.999999'
and id_iot in (select id_iot from iot where id_user='1')
AND id_face not IN (select id_face from dados_face where (id_loja IN (SELECT id_loja from loja where id_user='1') and id_grupo = '4'))
AND id_face in (select id_face from imagens where dt_cad < '2018-11-16' and id_iot in (select id_iot from iot where id_user='1') AND id_face not IN (select id_face from dados_face where (id_loja IN (SELECT id_loja from loja where id_user='1') and id_grupo = '4')))
GROUP BY d

Can anyone help me and explain to me how it works so I can bring the information even if there is no db count?

    
asked by anonymous 27.11.2018 / 15:54

0 answers