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 |
|
akhanna3
Starting Member
1 Post |
Posted - 2011-10-21 : 01:25:50
|
| Hi guys, Hoping you can help me out here. So I have a list of columns identifying an object (lets say columns A, B, C, D and E) and 3 sets of values for these objects (say columns 1, 2, 3)I’m trying to sum up 1,2 and 3 by columns A,B,C,D, E. So my code isSELECT A,B,C,D,E,SUM(1),SUM(2),SUM(3)FROM TABLEGROUP BY A,B,C,D,E;Problem is that I get two sets of rows for each A,B,C,D,E combination. The first row has only values in col. 1, while the second row has values for col. 2 and col. 3. I need to keep the rows distinct, and fill in the values of 1,2,3 in the relevant column for each distinct row.Can't seem to figure out what I'm doing wrong? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-10-21 : 02:27:33
|
it will be easier for us to understand your problem if you can post some sample data and the required result KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-10-21 : 02:53:32
|
| Have you tried this?SELECT D,E,SUM(A),SUM(B),SUM(C)FROM TABLEGROUP BY D,E;MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|