/****** Object:  View [dbo].[V_PAINEL_NFE_EST_NF_SAI_TRANSFERENCIA_CHECKIN_ENTRADA_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_EST_NF_SAI_TRANSFERENCIA_CHECKIN_ENTRADA_QTDE]')) 
  DROP VIEW [dbo].[V_PAINEL_NFE_EST_NF_SAI_TRANSFERENCIA_CHECKIN_ENTRADA_QTDE] 

GO

--SELECT * FROM V_PAINEL_NFE_EST_NF_SAI_TRANSFERENCIA_CHECKIN_ENTRADA_QTDE	WITH (NOLOCK)
CREATE VIEW [dbo].[V_PAINEL_NFE_EST_NF_SAI_TRANSFERENCIA_CHECKIN_ENTRADA_QTDE] AS
SELECT COUNT(1) AS QTDE_CHECKIN_ENTRADA
FROM EST_NF_SAI_PENDENCIA WITH (NOLOCK)
INNER JOIN EST_NF_SAI_CHECKIN_ENTRADA ON EST_NF_SAI_PENDENCIA.CD_EMP = EST_NF_SAI_CHECKIN_ENTRADA.CD_EMP
AND EST_NF_SAI_PENDENCIA.CD_FILIAL = EST_NF_SAI_CHECKIN_ENTRADA.CD_FILIAL
AND EST_NF_SAI_PENDENCIA.CD_NF = EST_NF_SAI_CHECKIN_ENTRADA.CD_NF
LEFT OUTER JOIN EST_NF_SAI_ERROS_VALIDACAO ON EST_NF_SAI_PENDENCIA.CD_EMP = EST_NF_SAI_ERROS_VALIDACAO.CD_EMP
AND EST_NF_SAI_PENDENCIA.CD_FILIAL = EST_NF_SAI_ERROS_VALIDACAO.CD_FILIAL
AND EST_NF_SAI_PENDENCIA.CD_NF = EST_NF_SAI_ERROS_VALIDACAO.CD_NF
WHERE EST_NF_SAI_ERROS_VALIDACAO.CD_NF IS NULL