SELECT DISTINCT B.COMPANY , A.ESTAB_ID_BRA , E.LANGUAGE_CD , E.DESCR FROM PS_ESTAB_ID_BRA A , PS_ESTAB_TBL B , PS_ESTAB_TBL_LANG E WHERE A.COUNTRY='BRA' AND A.ESTAB_ID_TYPE_BRA='CNPJ' AND B.ESTABID=A.ESTABID AND B.COUNTRY=A.COUNTRY AND A.EFFDT=( SELECT MAX(C.EFFDT) FROM PS_ESTAB_ID_BRA C WHERE C.ESTABID=A.ESTABID AND C.COUNTRY=A.COUNTRY AND C.ESTAB_ID_TYPE_BRA=A.ESTAB_ID_TYPE_BRA) AND B.EFFDT=( SELECT MAX(D.EFFDT) FROM PS_ESTAB_TBL D WHERE D.ESTABID=B.ESTABID) AND B.COMPANY= COMPANY AND E.ESTABID=B.ESTABID AND E.EFFDT = B.EFFDT
|