Sunday, 11 October 2020

SQL Query for Counting Records per Day,Month,Year in a single view

 

Display Download Count Day,Month,Year wise

Description:

In this example we explain that how to get download count Day, Month, Year wise in a single query Using SQL Query. Or how to get download count reports of Day, Month, Year in a single query using SQL Query.

Suppose you have to display some charts or report of the website viewer or mobile app download count for Day, Moth, Year wise at that time below SQL Query is useful to get the data.


Query:

SELECT    DATEPART(YEAR, DownloadDate) AS 'Year',

          DATEPART(MONTH, DownloadDate) AS 'Month',

          DATEPART(DAY, DownloadDate) AS 'Day',

          COUNT(*) AS 'Visits',

          DownloadDate

FROM      AppCounts

GROUP BY  DATEPART(DAY, DownloadDate),

          DATEPART(MONTH, DownloadDate),

          DATEPART(YEAR, DownloadDate),

          DownloadDate

ORDER BY  'Year',

          'Month',

          'Day'

 


This entry was posted in :

0 comments:

Post a Comment