/*
SELECT * FROM EST_PROD_PRECO_DESC_QTDE
SELECT * FROM EST_PROD_PRECO_DESC_QTDE_CPL
SELECT * FROM EST_PROD_PRECO_DESC_QTDE_PRC_FILIAL

*/

IF OBJECT_ID('V_EST_PROD_PRECO_DESC_QTDE_CPL_CARGA_PDV') IS NOT NULL
	DROP VIEW V_EST_PROD_PRECO_DESC_QTDE_CPL_CARGA_PDV
GO

CREATE VIEW V_EST_PROD_PRECO_DESC_QTDE_CPL_CARGA_PDV
AS
SELECT
TBL_FIL.CD_EMP,
TBL_FIL.CD_FILIAL,
TBL_FIL.CD_PRECO_DESC_QTDE,
TBL_PROD.CD_PROD,
TBL_PROD.QT_PROD,
TBL_PROD.QT_PROD_MAX,
TBL_PROD.PERC_DESC_QTDE

FROM	EST_PROD_PRECO_DESC_QTDE TBL
INNER	JOIN EST_PROD_PRECO_DESC_QTDE_PRC_FILIAL TBL_FIL
ON		TBL.CD_PRECO_DESC_QTDE = TBL_FIL.CD_PRECO_DESC_QTDE
INNER	JOIN EST_PROD_PRECO_DESC_QTDE_CPL TBL_PROD
ON		TBL_FIL.CD_EMP = TBL_PROD.CD_EMP AND TBL_FIL.CD_PRECO_DESC_QTDE = TBL_PROD.CD_PRECO_DESC_QTDE
