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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-03-24 : 18:09:38
|
Jonathan writes "I have a CUBE function which returns both the net and gross areas of a building (based on a room data table). The results are returned with a flag 1=net, 2=gross in mutiple rows as belowbuilding flag area1 1 1031 2 12110 1 234910 2 319911 1 204711 2 2972 I want to return the results as a single row per building as belowbuilding net gross1 103 12110 2349 234911 2047 2972 How can I achieve this?" |
|
|
rrb
SQLTeam Poet Laureate
1479 Posts |
Posted - 2002-03-24 : 19:16:54
|
Woops - sorry I didn't read the question properly.... I thought you wanted them concatenated into one column!Cheers nrEdited by - rrb on 03/24/2002 19:33:27 |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-03-24 : 19:28:16
|
| selectbuilding ,net = sum(case when flag = 1 then area else 0 end) ,gross sum(case when flag = 2 then area else 0 end)from #agroup by buildingorder by building==========================================Cursors are useful if you don't know sql.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|