Getting monthly and weekly data from daily in sql server

Learner 226 Reputation points
2022-05-17T07:28:21.09+00:00

Hello All,

I have a table like below.
I need to get daily,weekly and monthly calls data from this.

Could any one please help what is the query to write here

202686-image.png

Developer technologies | Transact-SQL
Developer technologies | Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
SQL Server | Other
0 comments No comments
{count} votes

Answer accepted by question author
  1. Olaf Helper 47,586 Reputation points
    2022-05-17T07:35:26.027+00:00

    Use a date function like YEAR, MONTH, DATEPART and an aggregation, like

    select YEAR(date) AS Year, MONTH(date) AS Month, SUM(Calls) AS Calls  
    from yourTable  
    group by YEAR(date), MONTH(date)  
    order by YEAR(date), MONTH(date)  
    

    for a monthly report.
    See https://learn.microsoft.com/en-us/sql/t-sql/functions/date-and-time-data-types-and-functions-transact-sql?view=sql-server-ver15#DateandTimeFunctions
    for details.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.