SELECT
    'S03' AS Sorter,
    DATE_FORMAT(:starttime, '%Y-%m-%d %H:%i') AS start_time,
    DATE_FORMAT(:endtime, '%Y-%m-%d %H:%i') AS end_time,
    'S03' AS sInduction_Name,

    CASE 
        WHEN TIMESTAMPDIFF(SECOND, :starttime, :endtime) = 0 THEN 0
        ELSE ROUND(COALESCE(sorter_total.total, 0) * 3600.0 
                   / TIMESTAMPDIFF(SECOND, :starttime, :endtime), 2)
    END AS total

FROM (SELECT 1) AS p
LEFT JOIN (
    SELECT
        COUNT(*) AS total
    FROM item_data
    WHERE t_stamp BETWEEN :starttime AND :endtime
      AND adiSort_Code_0 NOT IN (11, 15)
      AND sLocation_ID LIKE 'S03%'
) AS sorter_total ON 1 = 1;
