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,

    SUM(dc.ulc1 = 1) AS ULC1,
    SUM(dc.ulc2 = 1) AS ULC2,
    SUM(dc.ulc3 = 1) AS ULC3,
    SUM(dc.ulc4 = 1) AS ULC4,
    SUM(dc.ulc5 = 1) AS ULC5,
    SUM(dc.ulc6 = 1) AS ULC6,
    SUM(dc.ulc7 = 1) AS ULC7,
    SUM(dc.ulc8 = 1) AS ULC8

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