Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Not applicable

how to calculate sum for week,day ,month? In SQL SERVER

how to calculate sum for week,day ,month?

In SQL SERVER

4 Replies
MVP
MVP

Re: 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.



MVP
MVP

Re: how to calculate sum for week,day ,month? In SQL SERVER

Hi Yogesh,

Check this link it has various date formats

DATEPART (Transact-SQL)

Regards,

Jagan.

Not applicable

Re: how to calculate sum for week,day ,month? In SQL SERVER

hi jagan,

thanks...

please give anuy example you have?

MVP
MVP

Re: how to calculate sum for week,day ,month? In SQL SERVER

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.

Community Browser