Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

help in a sum query

help in a sum query

help in a sum query

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.

RE: help in a sum query

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: How to get the best answers

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


----signature below----
I'm pushing an elephant up the stairs

My Crummy Web Page

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close