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 |
aswindba1
Yak Posting Veteran
62 Posts |
Posted - 2013-04-29 : 17:19:27
|
I need add multiple rows and take sum of that row in to single columnServer|||| Costabcd ||||| 75abcd ||||| 25dtgr ||||| 65dtgr ||||| 35table should lok like below.Server||||| Costabcd ||||| 100abcd ||||| 100dtgr ||||| 100dtgr ||||| 100 orabcd |||||100dtgr |||||100 |
|
chadmat
The Chadinator
1974 Posts |
Posted - 2013-04-29 : 17:21:08
|
SELECT Server, SUM(Cost)FROM tableGROUP BY Server-Chad |
|
|
aswindba1
Yak Posting Veteran
62 Posts |
Posted - 2013-04-29 : 17:48:15
|
Hi Thanks for the reply..but when I am selecting the mutiple rows I am geting the follwoing error.Msg 8120, Level 16, State 1, Line 2Column 'Billing' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. |
|
|
chadmat
The Chadinator
1974 Posts |
Posted - 2013-04-29 : 17:53:52
|
Add the additional columns into the Group By Clause.ieSELECT Server, Billing, SUM(Cost)FROM tableGROUP BY Server, Billing-Chad |
|
|
aswindba1
Yak Posting Veteran
62 Posts |
Posted - 2013-04-29 : 18:23:38
|
Thanks alot..its working |
|
|
chadmat
The Chadinator
1974 Posts |
Posted - 2013-04-29 : 18:31:38
|
You are welcome.-Chad |
|
|
|
|
|