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 |
|
sindhu sarah
Starting Member
34 Posts |
Posted - 2011-11-29 : 09:23:48
|
| Hi all,I have temp table which displays the records as followingProjid Projname E1 E2 E3 E4 E5 E6 E7 E8100100 CAE - Telvent JV - for Revenue Recog. Only 0 0 2 0 0 0 0 0100100 CAE - Telvent JV - for Revenue Recog. Only 0 6 0 0 0 0 0 0100100 CAE - Telvent JV - for Revenue Recog. Only 0 0 0 0 0 0 3 0100100 CAE - Telvent JV - for Revenue Recog. Only 0 0 0 0 0 0 0 3100100 CAE - Telvent JV - for Revenue Recog. Only 0 0 0 2 0 0 0 0For the above table i dont want 0's to display.Istead i need as follows.Projid Projname E1 E2 E3 E4 E5 E6 E7 E8100100 CAE - Telvent JV - for Revenue Recog. Only 0 6 2 2 0 0 3 3Like it should display as one row instead duplication the projid.I gave distinct but still it did not work.is that possible to get the above table..Appreciate for the solutionThanks.. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-11-29 : 09:30:27
|
[code]select Projid, Projname, E1 = sum(E1), E2 = sum(E2), . . .from your_temp_tablegroup by Projid, Projname[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
sindhu sarah
Starting Member
34 Posts |
Posted - 2011-11-30 : 00:45:33
|
| Thanks for the solution khtan.Will try with it. |
 |
|
|
jassi.singh
Posting Yak Master
122 Posts |
Posted - 2011-11-30 : 01:36:34
|
| You want to sum of e1,....,sum of e8 for each project or do you want max of e1,....,max of e8 for each project? |
 |
|
|
|
|
|