-- WorkOrderTime Archive Query
-- Source: QADTA.F31122 (current) + ARCDTAQA.F31122 (archived)
-- Used by: GetWorkOrderTimesArchive() - on-demand historical retrieval
-- Note: Not scheduled, used for historical lookups

SELECT wot.WTUKID AS UniqueID,
       TRIM(wot.WTMMCU) AS BranchCode,
       wot.WTDOCO AS WorkOrderNumber,
       wot.WTOPSQ AS StepNumber,
       wot.WTAN8 AS AddressNumber,
       wot.WTDGL AS GlDate,
       wot.WTUPMJ AS DateUpdated,
       wot.WTTDAY AS TimeUpdated
  FROM QADTA.F31122 wot

UNION ALL

SELECT wot.WTUKID AS UniqueID,
       TRIM(wot.WTMMCU) AS BranchCode,
       wot.WTDOCO AS WorkOrderNumber,
       wot.WTOPSQ AS StepNumber,
       wot.WTAN8 AS AddressNumber,
       wot.WTDGL AS GlDate,
       wot.WTUPMJ AS DateUpdated,
       wot.WTTDAY AS TimeUpdated
  FROM ARCDTAQA.F31122 wot
