IF  EXISTS (SELECT * FROM SYS.VIEWS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[V_PAINEL_NFE_EST_NF_ENT_IT_DEVOLUCAO_PENDENCIA_QTDE]'))
DROP VIEW [DBO].[V_PAINEL_NFE_EST_NF_ENT_IT_DEVOLUCAO_PENDENCIA_QTDE]    
GO
--SELECT * FROM V_PAINEL_NFE_EST_NF_ENT_IT_DEVOLUCAO_PENDENCIA_QTDE
CREATE VIEW V_PAINEL_NFE_EST_NF_ENT_IT_DEVOLUCAO_PENDENCIA_QTDE
AS	
	SELECT 
		COUNT(DISTINCT EST_NF_ENT_IT_DEVOLUCAO.CD_NF) AS QTDE_DEVOLUCAO
	FROM 
		EST_NF_ENT_IT_DEVOLUCAO WITH (NOLOCK)
WHERE
	(EST_NF_ENT_IT_DEVOLUCAO.QTDE_PROD - EST_NF_ENT_IT_DEVOLUCAO.QTDE_PROD_DEVO_GERADA) > 0