CREATE OR REPLACE VIEW CONFIGURACAO_PAX_VOOM AS
SELECT CV.CDFILIAL, CV.CDCIA, CV.NRVOO, CV.CDTRECHO, NULL AS CDEQUIP, CV.CDCLASSE, NVL(CV.QTPAXVOO, 0) AS QTPAX
  FROM CONFIGVOO CV
  
UNION ALL

SELECT CE.CDFILIAL, CE.CDCIA, VT.NRVOO, VT.CDTRECHO, CE.CDEQUIP, CE.CDCLASSE, NVL(CE.QTPAXEQUI, 0) AS QTPAX
  FROM CONFIGEQUI CE
       INNER JOIN VOOTRECHO VT ON VT.CDFILIAL = CE.CDFILIAL AND
                                  VT.CDCIA = CE.CDCIA
 WHERE NOT EXISTS (SELECT 1
                     FROM CONFIGVOO
                    WHERE CDFILIAL = VT.CDFILIAL
                      AND CDCIA = VT.CDCIA
                      AND NRVOO = VT.NRVOO
                      AND CDTRECHO = VT.CDTRECHO)
ORDER BY CDFILIAL, CDCIA, NRVOO, CDTRECHO, CDEQUIP, CDCLASSE
/

CREATE OR REPLACE VIEW CONFIGURACAO_PAX_VOO_PRODM
AS
SELECT CV.CDFILIAL, CV.CDCIA, CV.NRVOO, CV.CDTRECHO, CV.CDEQUIP, CV.CDCLASSE, CV.QTPAX, O.NRORDEM
  FROM CONFIGURACAO_PAX_VOOM CV 
       INNER JOIN ORDCLASSEPROD O ON O.CDFILIAL = CV.CDFILIAL AND
                                     O.CDCLASSE = CV.CDCLASSE
ORDER BY CDFILIAL, CDCIA, NRVOO, CDTRECHO, CDEQUIP, NRORDEM, CDCLASSE
/