SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,865 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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
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.