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

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,682 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,552 questions
0 comments No comments
{count} votes

Accepted answer
  1. Olaf Helper 40,736 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