select distinct
a.business_unit,
a.cashier_office,
b.tender_key,
c.descr
from ps_csh_off_receipt a,
ps_csh_off_rcpt_t b,
PS_TENDER_KEY_TBL c
where a.business_unit=b.business_unit
and a.cashier_office=b.cashier_office
and a.receipt_nbr=b.receipt_nbr
and b.business_unit = c.business_unit
and b.tender_key=c.tender_key
and c.effdt =
(select max(cc.effdt)
from PS_TENDER_KEY_TBL cc
where c.business_unit = cc.business_unit
and c.tender_key = cc.tender_key
and cc.effdt <= %currentdatein
and cc.eff_status = 'A')
|