Query in mysql grouped by hour

Asked

Viewed 51 times

0

Good afternoon. I am performing a query in mysql and this returns the precise values.

My problem is to display the values that do not return by e.g.: I asked to group by hour or day it only returns the values that exist data. Already the values that have no data and should return the date with the count 0 do not return.

mine query is the following:

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

someone could help me and explain to me how it works so that I bring the information even if there is no count in db?

  • Help me here please

  • the query is right for ex let’s assume that I have counts in the days 14 15 and 17 but not have in the 16 it does not bring the day 16 being that I needed to return day 16 as 0

No answers

Browser other questions tagged

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