SELECT line.business_unit , line.invoice , line.line_seq_num , line.tax_cd , taxauth.tax_pct , taxauth.tax_authority_cd FROM ps_bi_line line , PS_BI_HDR hdr , ps_tax_cd tax , ps_tax_authority taxauth WHERE line.business_unit = hdr.business_unit AND line.invoice = hdr.invoice AND tax.setid = ( SELECT DISTINCT setid FROM ps_set_cntrl_rec WHERE setcntrlvalue = line.business_unit AND recname = 'TAX_CD') AND taxauth.setid = tax.setid AND tax.tax_authority_cd = taxauth.tax_authority_cd AND line.tax_cd = tax.tax_cd AND taxauth.effdt = ( SELECT MAX(effdt) FROM ps_tax_authority WHERE setid = taxauth.setid AND tax_authority_cd = taxauth.tax_authority_cd AND effdt <= hdr.invoice_dt) AND taxauth.eff_status = 'A'
|