SELECT
    CONCAT(DATE(dc.t_stamp), ' ', HOUR(dc.t_stamp), ':00') AS StartTimestamp,
    CONCAT('H', TIMESTAMPDIFF(HOUR,
        DATE_FORMAT(dc.t_stamp, "%Y-%m-%d %H:00:00"),
        DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))) AS Hour,

    CONCAT(CAST(SUM(dc.ulgl1 = 1) AS CHAR),' cph') AS ULGL1,
    CONCAT(CAST(SUM(dc.ulgl2 = 1) AS CHAR),' cph') AS ULGL2,
    CONCAT(CAST(SUM(dc.ulgl3 = 1) AS CHAR),' cph') AS ULGL3,
    CONCAT(CAST(SUM(dc.ulgl4 = 1) AS CHAR),' cph') AS ULGL4,
    CONCAT(CAST(SUM(dc.ulgl5 = 1) AS CHAR),' cph') AS ULGL5,
    CONCAT(CAST(SUM(dc.ulgl6 = 1) AS CHAR),' cph') AS ULGL6,
    CONCAT(CAST(SUM(dc.ulgl7 = 1) AS CHAR),' cph') AS ULGL7,
    CONCAT(CAST(SUM(dc.ulgl8 = 1) AS CHAR),' cph') AS ULGL8

FROM dumper_cycles dc
WHERE dc.t_stamp BETWEEN :starttime AND :endtime
GROUP BY HOUR(dc.t_stamp);
