Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Muj9
Yak Posting Veteran
75 Posts |
Posted - 2013-08-16 : 08:20:07
|
Hi all,i have a table which after a count(*) looks like this :-Fruits total Apple 2Banana 8Orange 5what i want is to work out the total in to the column so for example:-Fruits total Apple 2Banana 8Orange 5All_Fruit 15Can this be done?I will be very greatful to anyone who can help me.Thank you |
|
stepson
Aged Yak Warrior
545 Posts |
Posted - 2013-08-16 : 08:26:07
|
add:union allselect 'All Fruits',sum(total) as totalfrom QUERY Ce-am pe mine am si-n dulap, cand ma-mbrac zici ca ma mutsabinWeb |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-08-16 : 08:31:43
|
[code]1) SELECT Fruits, COUNT(*) total FROM TableName GROUP BY Fruits UNION SELECT 'All_Fruit', COUNT(*) FROM TableName2) SELECT Fruits, COUNT(*) total FROM TableName GROUP BY Fruits WITH ROLLUP [/code]--Chandu |
|
|
Muj9
Yak Posting Veteran
75 Posts |
Posted - 2013-08-16 : 08:43:41
|
Hi thank you all for your help.i used SELECT Fruits, COUNT(*) total FROM TableName GROUP BY Fruits WITH ROLLUPbrilliant.Thank you |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-08-16 : 08:47:07
|
quote: Originally posted by Muj9 Hi thank you all for your help.i used SELECT Fruits, COUNT(*) total FROM TableName GROUP BY Fruits WITH ROLLUPbrilliant.Thank you
Welcome--Chandu |
|
|
|
|
|