select t.AccountId,
t.ReceiptType,
t.BatchID,
Case
when t.printshop = 'ImpressionsDirect' then b.OutsourcedMailedUTC
when t.printshop = 'LHM' then b.InternalMailedUTC
else NULL
End as HistoryDate
from receipts.PrintBatchTransactions t join receipts.printbatch b on b.PrintBatchId
where t.PrintBatchId = 'P181011.130439'
order by
t.ReceiptType
Thank you that worked