Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL - Calculating Monthly and Year-To-Date totals in the same query

Status
Not open for further replies.

sivi

IS-IT--Management
Nov 27, 2002
27
GB
I need to caluculate Monthly (current) and Year-To-Date totals of the same value in the same query.

I am using SUM & GROUPBY commands with WHERE clause, this is working for monthly totals, but to have YTD totals I will need another WHERE clause.

I tried to have another SELECT, which is giving error.

Please could someone help me on this.

Many Thanks
Sivi
 
What you need to do is look up "cross-tab reports" in BOL...

They have a greate example. It shows creating a query for 4 quaters with a 4 case statements... All you need is 13 cols.. 12 cases for each of the months and 1 sum of the year..

Concept should be exactly the same.

Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top