SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[view_VisitPv]
AS
SELECT     TOP (100) PERCENT ISNULL(pv, 0) AS pv, hour
FROM         (SELECT     SUM(number) AS pv, 0 AS hour
                       FROM          dbo.Visit_Site
                       WHERE      (DATEPART(day, addtime) = DATEPART(day, GETDATE())) AND (DATEPART(hour, updatetime) = 0)
                       UNION
                       SELECT     SUM(number) AS pv, 1 AS hour
                       FROM         dbo.Visit_Site AS visit_site_47
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE())) AND (DATEPART(hour, updatetime) = 1)
                       UNION
                       SELECT     SUM(number) AS pv, 2 AS hour
                       FROM         dbo.Visit_Site AS visit_site_46
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE())) AND (DATEPART(hour, updatetime) = 2)
                       UNION
                       SELECT     SUM(number) AS pv, 3 AS hour
                       FROM         dbo.Visit_Site AS visit_site_45
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE())) AND (DATEPART(hour, updatetime) = 3)
                       UNION
                       SELECT     SUM(number) AS pv, 4 AS hour
                       FROM         dbo.Visit_Site AS visit_site_44
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE())) AND (DATEPART(hour, updatetime) = 4)
                       UNION
                       SELECT     SUM(number) AS pv, 5 AS hour
                       FROM         dbo.Visit_Site AS visit_site_43
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE())) AND (DATEPART(hour, updatetime) = 5)
                       UNION
                       SELECT     SUM(number) AS pv, 6 AS hour
                       FROM         dbo.Visit_Site AS visit_site_42
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE())) AND (DATEPART(hour, updatetime) = 6)
                       UNION
                       SELECT     SUM(number) AS pv, 7 AS hour
                       FROM         dbo.Visit_Site AS visit_site_41
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE())) AND (DATEPART(hour, updatetime) = 7)
                       UNION
                       SELECT     SUM(number) AS pv, 8 AS hour
                       FROM         dbo.Visit_Site AS visit_site_40
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE())) AND (DATEPART(hour, updatetime) = 8)
                       UNION
                       SELECT     SUM(number) AS pv, 9 AS hour
                       FROM         dbo.Visit_Site AS visit_site_39
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE())) AND (DATEPART(hour, updatetime) = 9)
                       UNION
                       SELECT     SUM(number) AS pv, 10 AS hour
                       FROM         dbo.Visit_Site AS visit_site_38
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE())) AND (DATEPART(hour, updatetime) = 10)
                       UNION
                       SELECT     SUM(number) AS pv, 11 AS hour
                       FROM         dbo.Visit_Site AS visit_site_37
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE())) AND (DATEPART(hour, updatetime) = 11)
                       UNION
                       SELECT     SUM(number) AS pv, 12 AS hour
                       FROM         dbo.Visit_Site AS visit_site_36
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE())) AND (DATEPART(hour, updatetime) = 12)
                       UNION
                       SELECT     SUM(number) AS pv, 13 AS hour
                       FROM         dbo.Visit_Site AS visit_site_35
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE())) AND (DATEPART(hour, updatetime) = 13)
                       UNION
                       SELECT     SUM(number) AS pv, 14 AS hour
                       FROM         dbo.Visit_Site AS visit_site_34
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE())) AND (DATEPART(hour, updatetime) = 14)
                       UNION
                       SELECT     SUM(number) AS pv, 15 AS hour
                       FROM         dbo.Visit_Site AS visit_site_33
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE())) AND (DATEPART(hour, updatetime) = 15)
                       UNION
                       SELECT     SUM(number) AS pv, 16 AS hour
                       FROM         dbo.Visit_Site AS visit_site_32
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE())) AND (DATEPART(hour, updatetime) = 16)
                       UNION
                       SELECT     SUM(number) AS pv, 17 AS hour
                       FROM         dbo.Visit_Site AS visit_site_31
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE())) AND (DATEPART(hour, updatetime) = 17)
                       UNION
                       SELECT     SUM(number) AS pv, 18 AS hour
                       FROM         dbo.Visit_Site AS visit_site_30
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE())) AND (DATEPART(hour, updatetime) = 18)
                       UNION
                       SELECT     SUM(number) AS pv, 19 AS hour
                       FROM         dbo.Visit_Site AS visit_site_29
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE())) AND (DATEPART(hour, updatetime) = 19)
                       UNION
                       SELECT     SUM(number) AS pv, 20 AS hour
                       FROM         dbo.Visit_Site AS visit_site_28
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE())) AND (DATEPART(hour, updatetime) = 20)
                       UNION
                       SELECT     SUM(number) AS pv, 21 AS hour
                       FROM         dbo.Visit_Site AS visit_site_27
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE())) AND (DATEPART(hour, updatetime) = 21)
                       UNION
                       SELECT     SUM(number) AS pv, 22 AS hour
                       FROM         dbo.Visit_Site AS visit_site_26
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE())) AND (DATEPART(hour, updatetime) = 22)
                       UNION
                       SELECT     SUM(number) AS pv, 23 AS hour
                       FROM         dbo.Visit_Site AS visit_site_25
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE())) AND (DATEPART(hour, updatetime) = 23)
                       UNION
                       SELECT     SUM(number) AS yespv, 24 AS hour
                       FROM         dbo.Visit_Site AS visit_site_24
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE()) - 1) AND (DATEPART(hour, updatetime) = 0)
                       UNION
                       SELECT     SUM(number) AS yespv, 25 AS hour
                       FROM         dbo.Visit_Site AS visit_site_23
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE()) - 1) AND (DATEPART(hour, updatetime) = 1)
                       UNION
                       SELECT     SUM(number) AS yespv, 26 AS hour
                       FROM         dbo.Visit_Site AS visit_site_22
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE()) - 1) AND (DATEPART(hour, updatetime) = 2)
                       UNION
                       SELECT     SUM(number) AS yespv, 27 AS hour
                       FROM         dbo.Visit_Site AS visit_site_21
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE()) - 1) AND (DATEPART(hour, updatetime) = 3)
                       UNION
                       SELECT     SUM(number) AS yespv, 28 AS hour
                       FROM         dbo.Visit_Site AS visit_site_20
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE()) - 1) AND (DATEPART(hour, updatetime) = 4)
                       UNION
                       SELECT     SUM(number) AS yespv, 29 AS hour
                       FROM         dbo.Visit_Site AS visit_site_19
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE()) - 1) AND (DATEPART(hour, updatetime) = 5)
                       UNION
                       SELECT     SUM(number) AS yespv, 30 AS hour
                       FROM         dbo.Visit_Site AS visit_site_18
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE()) - 1) AND (DATEPART(hour, updatetime) = 6)
                       UNION
                       SELECT     SUM(number) AS yespv, 31 AS hour
                       FROM         dbo.Visit_Site AS visit_site_17
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE()) - 1) AND (DATEPART(hour, updatetime) = 7)
                       UNION
                       SELECT     SUM(number) AS yespv, 32 AS hour
                       FROM         dbo.Visit_Site AS visit_site_16
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE()) - 1) AND (DATEPART(hour, updatetime) = 8)
                       UNION
                       SELECT     SUM(number) AS yespv, 33 AS hour
                       FROM         dbo.Visit_Site AS visit_site_15
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE()) - 1) AND (DATEPART(hour, updatetime) = 9)
                       UNION
                       SELECT     SUM(number) AS yespv, 34 AS hour
                       FROM         dbo.Visit_Site AS visit_site_14
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE()) - 1) AND (DATEPART(hour, updatetime) = 10)
                       UNION
                       SELECT     SUM(number) AS yespv, 35 AS hour
                       FROM         dbo.Visit_Site AS visit_site_13
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE()) - 1) AND (DATEPART(hour, updatetime) = 11)
                       UNION
                       SELECT     SUM(number) AS yespv, 36 AS hour
                       FROM         dbo.Visit_Site AS visit_site_12
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE()) - 1) AND (DATEPART(hour, updatetime) = 12)
                       UNION
                       SELECT     SUM(number) AS yespv, 37 AS hour
                       FROM         dbo.Visit_Site AS visit_site_11
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE()) - 1) AND (DATEPART(hour, updatetime) = 13)
                       UNION
                       SELECT     SUM(number) AS yespv, 38 AS hour
                       FROM         dbo.Visit_Site AS visit_site_10
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE()) - 1) AND (DATEPART(hour, updatetime) = 14)
                       UNION
                       SELECT     SUM(number) AS yespv, 39 AS hour
                       FROM         dbo.Visit_Site AS visit_site_9
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE()) - 1) AND (DATEPART(hour, updatetime) = 15)
                       UNION
                       SELECT     SUM(number) AS yespv, 40 AS hour
                       FROM         dbo.Visit_Site AS visit_site_8
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE()) - 1) AND (DATEPART(hour, updatetime) = 16)
                       UNION
                       SELECT     SUM(number) AS yespv, 41 AS hour
                       FROM         dbo.Visit_Site AS visit_site_7
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE()) - 1) AND (DATEPART(hour, updatetime) = 17)
                       UNION
                       SELECT     SUM(number) AS yespv, 42 AS hour
                       FROM         dbo.Visit_Site AS visit_site_6
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE()) - 1) AND (DATEPART(hour, updatetime) = 18)
                       UNION
                       SELECT     SUM(number) AS yespv, 43 AS hour
                       FROM         dbo.Visit_Site AS visit_site_5
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE()) - 1) AND (DATEPART(hour, updatetime) = 19)
                       UNION
                       SELECT     SUM(number) AS yespv, 44 AS hour
                       FROM         dbo.Visit_Site AS visit_site_4
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE()) - 1) AND (DATEPART(hour, updatetime) = 20)
                       UNION
                       SELECT     SUM(number) AS yespv, 45 AS hour
                       FROM         dbo.Visit_Site AS visit_site_3
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE()) - 1) AND (DATEPART(hour, updatetime) = 21)
                       UNION
                       SELECT     SUM(number) AS yespv, 46 AS hour
                       FROM         dbo.Visit_Site AS visit_site_2
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE()) - 1) AND (DATEPART(hour, updatetime) = 22)
                       UNION
                       SELECT     SUM(number) AS yespv, 47 AS hour
                       FROM         dbo.Visit_Site AS visit_site_1
                       WHERE     (DATEPART(day, addtime) = DATEPART(day, GETDATE()) - 1) AND (DATEPART(hour, updatetime) = 23)) AS cc
ORDER BY hour

GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4[30] 2[40] 3) )"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "cc"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 95
               Right = 177
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
      Begin ColumnWidths = 9
         Width = 284
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'VIEW', @level1name=N'view_VisitPv'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'VIEW', @level1name=N'view_VisitPv'
