SELECT
    t_stamp AS `Timestamp`,
    'S01' AS `Sorter`,
    sLocation_ID AS `Scanner`,
    id AS `Parcel ID`,
    sBarcode AS `Scan Label`,
    CASE 
        WHEN adiSort_Code_0 = 8 THEN 'No_Read'
        WHEN adiSort_Code_0 = 9 THEN 'No_Code'
        WHEN adiSort_Code_0 = 10 THEN 'Multi_Label'
        ELSE 'Good Read'
    END AS `Scan Status`,
    iPackage_Length AS `Item Length`,
    asRequested_Dest_ID_0 AS `Requested Destination`,
    sActual_Dest_ID AS `Actual Destination`,
    adiSort_Code_0 AS `Reason Code`
FROM item_data
WHERE t_stamp BETWEEN :starttime AND :endtime

UNION ALL

SELECT
    :starttime AS `Timestamp`,
    'S01' AS `Sorter`,
    'N/A' AS `Scanner`,
    0 AS `Parcel ID`,
    'N/A' AS `Scan Label`,
    'N/A' AS `Scan Status`,
    0 AS `Item Length`,
    'N/A' AS `Requested Destination`,
    'N/A' AS `Actual Destination`,
    0 AS `Reason Code`
WHERE NOT EXISTS (
    SELECT 1 FROM item_data 
    WHERE t_stamp BETWEEN :starttime AND :endtime
)

ORDER BY `Timestamp`;