select distinct c.company, a.tax_location_cd, a1.language_cd, a1.descr from PS_TAX_LOCATION1 a,
ps_tax_location2 b,
ps_co_statetax_tbl c,
ps_co_localtax_tbl l,
ps_tax_locat1_lang a1
where
a.eff_status='A'
and a.tax_location_cd=a1.tax_location_cd
and a.tax_location_cd=b.tax_location_cd
and b.state=c.state
and c.effdt=(select max(d.effdt)
from ps_co_statetax_tbl d where c.company=d.company and c.state=d.state)
and (b.locality=' '
or (b.locality<>' '
and c.company=l.company
and b.state=l.state
and b.locality=l.locality
and l.effdt=(select max(m.effdt)
from ps_co_localtax_tbl m where l.company=m.company
and l.state=m.state and l.locality=m.locality)))
and (b.locality_link=' '
or (b.locality_link<>' '
and c.company=l.company
and b.state=l.state
and b.locality_link=l.locality
and l.effdt=(select max(n.effdt) from ps_co_localtax_tbl n
where l.company=n.company and l.state=n.state
and l.locality=n.locality)))
|