SELECT 
    CONCAT(DATE(t_stamp), ' ', HOUR(t_stamp), ':00') AS `Start Timestamp`,
    CONCAT('H', TIMESTAMPDIFF(HOUR, DATE_FORMAT(t_stamp, "%Y-%m-%d %H:00:00"), DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))) AS `Hour`,
    sInduction_Name AS `Induction Name`,
    COALESCE(SUM(diTotal_Single_Carrier), 0) AS `Total Single Carrier`,
    COALESCE(SUM(diTotal_Double_Carrier), 0) AS `Total Double Carrier`,
    COALESCE(SUM(diTotal_Single_Carrier), 0) + COALESCE(SUM(diTotal_Double_Carrier), 0) AS `Total`
FROM induction_data
WHERE t_stamp BETWEEN :starttime AND :endtime
    AND (sInduction_Name = :inductionname OR :inductionname IS NULL OR :inductionname = '')
GROUP BY DATE(t_stamp), HOUR(t_stamp), sInduction_Name
ORDER BY DATE(t_stamp) ASC, HOUR(t_stamp) ASC;

