SELECT DISTINCT C.COMPANY , A.TAX_LOCATION_CD , A.DESCR FROM PS_TAX_LOCATION1 A , PS_TAX_LOCATION2 B , PS_CO_STATETAX_TBL C WHERE A.EFF_STATUS='A' 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 C.EFF_STATUS = 'A' AND (B.LOCALITY=' ' OR EXISTS ( SELECT 'X' FROM PS_CO_LOCALTAX_TBL L WHERE 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 EXISTS ( SELECT 'X' FROM PS_CO_LOCALTAX_TBL L WHERE 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 ) ) )
|