IF OBJECT_ID('V_PARCIAL_ATRASO_CONSOLIDACAO') IS NOT NULL
DROP VIEW
	 V_PARCIAL_ATRASO_CONSOLIDACAO;
GO

CREATE VIEW V_PARCIAL_ATRASO_CONSOLIDACAO
AS
	 SELECT
			ABS(DATEDIFF(MINUTE, DT_CONSD, HR_VD)) AS ATRASO
		  , COUNT(0) AS QTDE
	 FROM
		 PDV_VD
	 WHERE  DT_VD = CONVERT(DATE, GETDATE())
	 GROUP BY
			  ABS(DATEDIFF(MINUTE, DT_CONSD, HR_VD));