SELECT 
    COALESCE(data.roundtime, 'N/A') AS StartTimestamp,
    COALESCE(
        CONCAT(
            'H',
            TIMESTAMPDIFF(
                HOUR,
                DATE_FORMAT(data.roundtime, "%Y-%m-%d %H:00:00"),
                DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00")
            )
        ),
        'N/A'
    ) AS Hour,
    COALESCE(data.sInduction_Name, 'N/A') AS sInduction_Name,
    COALESCE(data.Count, 0) AS Count
FROM (SELECT 1) AS p
LEFT JOIN (
    SELECT 
        CONCAT(DATE(t_stamp), ' ', HOUR(t_stamp), ':00') AS roundtime,
        'S03' AS sInduction_Name,
        COUNT(*) AS Count
    FROM item_data
    WHERE t_stamp BETWEEN :starttime AND :endtime
        AND adiSort_Code_0 NOT IN (11, 15)
        AND sLocation_ID LIKE 'S03%'
    GROUP BY DATE(t_stamp), HOUR(t_stamp)
) AS data ON 1=1
ORDER BY data.roundtime ASC;
