/****** Object:  View [dbo].[V_PAINEL_NFE_DANFE_ERROS_VALIDACAO_IMPOSTO_QTDE]    Script Date: 17/11/2018 11:00:00 ******/ 
IF EXISTS (SELECT * 
           FROM   SYS.VIEWS 
           WHERE  OBJECT_ID = 
      Object_id(N'[dbo].[V_PAINEL_NFE_DANFE_ERROS_VALIDACAO_IMPOSTO_QTDE]')) 
  DROP VIEW [dbo].[V_PAINEL_NFE_DANFE_ERROS_VALIDACAO_IMPOSTO_QTDE] 

GO

--SELECT * FROM V_PAINEL_NFE_DANFE_ERROS_VALIDACAO_IMPOSTO_QTDE	WITH (NOLOCK)
CREATE VIEW [dbo].[V_PAINEL_NFE_DANFE_ERROS_VALIDACAO_IMPOSTO_QTDE] AS
SELECT COUNT(EST_NF_ENT_DANFE_PROVISORIO.CD_CTR) AS QTDE_ERROS
FROM EST_NF_ENT_DANFE_PROVISORIO
WHERE EST_NF_ENT_DANFE_PROVISORIO.CD_EMP=1
  AND EXISTS
    (SELECT CD_CTR
     FROM EST_NF_ENT_DANFE_PROVISORIO_ITENS_VALIDACAO_IMPOSTO_ERROS_VALIDACAO i
     WHERE EST_NF_ENT_DANFE_PROVISORIO.CD_CTR = i.CD_CTR)