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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help in a sum query

Status
Not open for further replies.

yehong

Programmer
Sep 22, 2003
291
0
0
US
Hi Guys, I am on a tight deadline. I have a query that returns data similar to the following:

State City JanSum FebSum MarSum... DecSum
CA LA 1000 500 300 ... 200
CA SF 500 500 200 ... 300
TX Dallas 300 100 50 ... 150
TX Hou 120 400 0 ... 0

I need help in writing a query that returns the results as follows:

State City JanSum FebSum MarSum... DecSum
All All 1920 1500 550 650
All LA ... ... ... ...
All SF ...
All Dallas ...
All Hou ...
CA All ...
TX All ...

Is this achievable through a query? I am using SQL Server database. Please advise how to achieve this with some sample code if possible. Thanks in advance.
 
You'll need to use a union query. This is more of a question for the SQL Server Programming forum.

As an aside, I think you need to read this: faq222-2244

It is nice to post back and let people who've offered advice know whether it worked or not.

Alex


[small]----signature below----[/small]
I'm pushing an elephant up the stairs

My Crummy Web Page
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top