mysql show records per hour

0

Greetings I need to group records per hour in a range (from 7 to 16) in mysql but I also need to show the hours where there is no record if there was at 7, 8, 9 but at 10 there are no records I need to leave the time and maybe a zero if there are null results

For example I have this query

select HOUR(created_at) as hora, asunto as name, COUNT(turno) as numero from tikets 
where estado = 1 and id_sucursal = 1 
and asunto = 'Factibilidad' 
and DATE(created_at) = '2017-06-14'
GROUP BY hora ASC 

that throws me this:

and I take care that I throw something like that

Some idea of how I could raise it if I need another table or how I could do the selection would be appreciated

    
asked by Esteban Flores 17.06.2017 в 02:23
source

2 answers

0

For this, what you need is to use ISNULL (column, 'value if null'), where your sentence would be:

ISNULL(columna, 0)

If you could edit your question with the tables and some data could give you the specific sentence, greetings.

    
answered by 17.06.2017 в 02:49
0
SELECT HORA,IFNULL(NUM_TURNOS,0) FROM MITABLA;

I think you should update your question, or say what is your use.

    
answered by 17.06.2017 в 03:09