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

Column Sum 1

Status
Not open for further replies.

berkshirea

Technical User
Mar 22, 2009
97
GB
hi guys, can you give me some ideas please?

i have a table like this
Code:
col1    col2   col3
fruits fruitsA 2
fruits fruitsB 2
fruits fruitsC 1
fruits fruitsD 9
vegies vegiesA 2
vegies vegiesB 4
vegies vegiesC 3
drinks drinksA 1
drinks drinksB 3
drinks drinksC 4
drinks drinksD 3
drinks drinksE 1

and want to have a recordset something like this:

Code:
col1    col2   col3
fruits fruitsA 2
fruits fruitsB 2
fruits fruitsC 1
fruits fruitsD 9
fruits         14  
vegies vegiesA 2
vegies vegiesB 4
vegies vegiesC 3
vegies         9
drinks drinksA 1
drinks drinksB 3
drinks drinksC 4
drinks drinksD 3
drinks drinksE 1
drinks         12

is this doable? thanks for any suggestions.


 

Have a look at the ROLLUP clause as part of your group by

Code:
Select Col1, Col2 sum(Col3)
From   YourTable
Group By Col1, Col2 WITH ROLLUP

I love deadlines. I like the whooshing sound they make as they fly by
Douglas Adams
(1952-2001)
 
Wow thanks very much dhulbert, that did it!!!
Have a nice day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top