Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

SQL Server: Daten zusammenfassen nach Datum gruppiert

17.05.2018 (👁8020)

SQL Server: Daten Zählen nach Datum gruppiert

 

Das folgende SQL Transact Code-Beispiel kummuliert die Anzahl aller Datensätze an einem Tag zusammen.

Dabei wird die Anzahl anhand der ID hochgezählt

SELECT   COUNT(IDViewLog) AS nViews,

 

Und Ăźber dem Tages-Datum zusammengefasst

GROUP BY CAST(dtView AS date)

 

 

Beispiel

/****** Script for SelectTopNRows command from SSMS  ******/

SELECT   COUNT(IDViewLog) AS nViews, CAST(dtView AS date) as DateViews

FROM     tbl_Notes_View_Log

GROUP BY CAST(dtView AS date)

ORDER BY CAST(dtView AS date) DESC

 

 

 

Wichtig ist dabei, dass das eigentliche Datum als Zeitstempel mit Datum Uhrzeit bis zur Millisekunde gespeichert ist

/****** Script for SelectTopNRows command from SSMS  ******/

SELECT TOP (1000) [IDViewLog]

      ,[IDNote]

      ,[IDUser]

      ,[dtView]

  FROM [readdy].[dbo].[tbl_Notes_View_Log]

 

IDViewLog    IDNote         IDUser         dtView

1        0        1        2018-02-26 11:45:50.997

2        0        1        2018-02-26 13:26:13.260

3        0        1        2018-02-26 13:29:44.320

4        0        1        2018-02-26 13:29:49.973

5        0        1        2018-02-26 13:29:50.487