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 |
|
sqlneve
Starting Member
16 Posts |
Posted - 2008-11-20 : 17:34:04
|
i have a query that works well enough as followsSELECT SUM (MAX_MONTHL)--SELECT *FROM SDE.TESTWHERE SURVEY = 'wallace, l'but i have almost 200 different surveys to run it on... it there a better way to do this rather than one by one? Is there a way to say where survey name is unique and get an output of all surveys with their sums? or am i just being crazy?  |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2008-11-20 : 17:41:20
|
| select SURVEY, SUM (MAX_MONTHL)from SDE.TESTgroup by SURVEYCould put in a where clause if you don't want all surveys==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
DavidChel
Constraint Violating Yak Guru
474 Posts |
Posted - 2008-11-20 : 17:41:54
|
| Umm.. how about:SELECT SUM (MAX_MONTHL)FROM SDE.TESTGROUP BY SURVEY |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-21 : 01:56:19
|
quote: Originally posted by DavidChel Umm.. how about:SELECT SUM (MAX_MONTHL)FROM SDE.TESTGROUP BY SURVEY
no probelm but only thing is you need to include the grouped field as well in select else you wont be able to identify which sum value corresponds to which SURVEY. See previous solution provided. |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2008-11-21 : 02:55:35
|
| And that's a post that adds little to the threadJust like this one.(sorry I'm drunk)==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
DavidChel
Constraint Violating Yak Guru
474 Posts |
Posted - 2008-11-21 : 09:20:05
|
quote: Originally posted by visakh16
quote: Originally posted by DavidChel Umm.. how about:SELECT SUM (MAX_MONTHL)FROM SDE.TESTGROUP BY SURVEY
no probelm but only thing is you need to include the grouped field as well in select else you wont be able to identify which sum value corresponds to which SURVEY. See previous solution provided.
Oops, duh. |
 |
|
|
sqlneve
Starting Member
16 Posts |
Posted - 2008-11-21 : 09:22:51
|
| thanks everyone... this really helped me out! |
 |
|
|
NeilG
Aged Yak Warrior
530 Posts |
Posted - 2008-11-21 : 09:30:28
|
| Your only saving grace on this one nigel is that the time is showen as 24hrs otherwise i would be worried at you being drunk at 2:55 in the afternoon :-) |
 |
|
|
|
|
|