Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Query Help Expand / Collapse
Author
Message
Posted Monday, April 29, 2013 3:53 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Thursday, April 24, 2014 8:19 PM
Points: 56, Visits: 240
I need add multiple rows and take sum of that row in to single column


Server|||| Cost

abcd ||||| 75
abcd ||||| 25
dtgr ||||| 65
dtgr ||||| 35

table should lok like below.

Server||||| Cost
abcd ||||| 100
abcd ||||| 100
dtgr ||||| 100
dtgr ||||| 100

or

abcd |||||100
dtgr |||||100
Post #1447798
Posted Monday, April 29, 2013 4:00 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 4:56 PM
Points: 23,400, Visits: 32,256
DBA12345 (4/29/2013)
I need add multiple rows and take sum of that row in to single column


Server|||| Cost

abcd ||||| 75
abcd ||||| 25
dtgr ||||| 65
dtgr ||||| 35

table should lok like below.

Server||||| Cost
abcd ||||| 100
abcd ||||| 100
dtgr ||||| 100
dtgr ||||| 100

or

abcd |||||100
dtgr |||||100



select
Server,
sum(Cost) as TotalCost
from
dbo.MyTable
group by
Server
order by
Server;





Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1447799
Posted Monday, April 29, 2013 4:23 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Thursday, April 24, 2014 8:19 PM
Points: 56, Visits: 240
Thanks alot..its working
Post #1447808
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse