Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
how to calculate sum for week,day ,month?
In SQL SERVER
Hi Yogesh,
Try like this
For Week:
SELECT
DATEPART (wk, DateFieldName) AS Week,
Sum(Sales) AS Sales
FROM TableName
Group By DATEPART (wk, DateFieldName);
For Month:
SELECT
DATEPART (m, DateFieldName) AS Month,
Sum(Sales) AS Sales
FROM TableName
Group By DATEPART (m, DateFieldName);
For Day:
SELECT
DATEPART (d, DateFieldName) AS Day,
Sum(Sales) AS Sales
FROM TableName
Group By DATEPART (d, DateFieldName);
Regards,
Jagan.
hi jagan,
thanks...
please give anuy example you have?
Hi,
Check this in your database tables, if you want to practice download Northwind or Pubs or Adventureworks database and practice.
Please close this thread by giving correct and helpful answers to the useful posts.
Regards,
Jagan.