Buenos días! Para empezar creo que lo que necesitas es la funcion `HOUR()`de MySQL, que te devuelve la hora. Incluso si quieres hacerlo por franjas de media hora puedes utilizar la funcion `MINUTE()` para obtener los minutos de un timestamp. Una vez con esto puedes hacer la consulta sumando los registros que cumplan los IFs, así tendrás la suma por franja horaria. Por ejemplo, para franjas horarias de horas enteras tendrías algo así: SELECT SUM(if(HOUR(T.TIME_CONTACT) = 0, 1, 0)) AS FRANJA_0, SUM(if(HOUR(T.TIME_CONTACT) = 1, 1, 0)) AS FRANJA_1, SUM(if(HOUR(T.TIME_CONTACT) = 2, 1, 0)) AS FRANJA_2, SUM(if(HOUR(T.TIME_CONTACT) = 3, 1, 0)) AS FRANJA_3, SUM(if(HOUR(T.TIME_CONTACT) = 4, 1, 0)) AS FRANJA_4, SUM(if(HOUR(T.TIME_CONTACT) = 5, 1, 0)) AS FRANJA_5, SUM(if(HOUR(T.TIME_CONTACT) = 6, 1, 0)) AS FRANJA_6, SUM(if(HOUR(T.TIME_CONTACT) = 7, 1, 0)) AS FRANJA_7, SUM(if(HOUR(T.TIME_CONTACT) = 8, 1, 0)) AS FRANJA_8, SUM(if(HOUR(T.TIME_CONTACT) = 9, 1, 0)) AS FRANJA_9, SUM(if(HOUR(T.TIME_CONTACT) = 10, 1, 0)) AS FRANJA_10, SUM(if(HOUR(T.TIME_CONTACT) = 11, 1, 0)) AS FRANJA_11, SUM(if(HOUR(T.TIME_CONTACT) = 12, 1, 0)) AS FRANJA_12, SUM(if(HOUR(T.TIME_CONTACT) = 13, 1, 0)) AS FRANJA_13, SUM(if(HOUR(T.TIME_CONTACT) = 14, 1, 0)) AS FRANJA_14, SUM(if(HOUR(T.TIME_CONTACT) = 15, 1, 0)) AS FRANJA_15, SUM(if(HOUR(T.TIME_CONTACT) = 16, 1, 0)) AS FRANJA_16, SUM(if(HOUR(T.TIME_CONTACT) = 17, 1, 0)) AS FRANJA_17, SUM(if(HOUR(T.TIME_CONTACT) = 18, 1, 0)) AS FRANJA_18, SUM(if(HOUR(T.TIME_CONTACT) = 19, 1, 0)) AS FRANJA_19, SUM(if(HOUR(T.TIME_CONTACT) = 20, 1, 0)) AS FRANJA_20, SUM(if(HOUR(T.TIME_CONTACT) = 21, 1, 0)) AS FRANJA_21, SUM(if(HOUR(T.TIME_CONTACT) = 22, 1, 0)) AS FRANJA_22, SUM(if(HOUR(T.TIME_CONTACT) = 23, 1, 0)) AS FRANJA_23 FROM DIFERIDAS T; Editado una vez nos has pasado la tabla real que estás usando. Espero te sea útil!