SELECT h.business_unit , h.po_id , b.line_nbr , b.sched_nbr , b.distrib_line_num , c.foreign_currency , c.base_currency , MIN(c.ledger_group) , SUM(c.foreign_amount) , SUM(c.monetary_amount) FROM ps_kk_shdr_poenc a , ps_kk_source_ln b , ps_kk_liquidation c , PS_PO_HDR h WHERE a.business_unit = h.business_unit AND a.po_id = h.po_id AND h.po_status NOT IN ('C','X') AND ((h.budget_hdr_status <> 'V' AND h.budget_hdr_sts_np <> 'V') OR (h.budget_hdr_status = 'V' AND h.budget_hdr_sts_np <> 'V') OR (h.budget_hdr_status <> 'V' AND h.budget_hdr_sts_np = 'V')) AND h.mid_roll_status = 'Y' AND a.kk_source_tran = 'PO_POENC' AND a.kk_rolled_seq = 0 AND a.kk_tran_id = b.kk_tran_id AND a.kk_tran_dt = b.kk_tran_dt AND b.kk_tran_id = c.kk_tran_id AND b.kk_tran_dt = c.kk_tran_dt AND b.kk_tran_ln = c.kk_tran_ln GROUP BY h.business_unit, h.po_id, b.line_nbr, b.sched_nbr, b.distrib_line_num, c.foreign_currency, c.base_currency, c.ledger_group
|