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 |
|
issammansour
Yak Posting Veteran
51 Posts |
Posted - 2007-08-20 : 14:09:17
|
| Hi,How to use select statement group by with more than one variable at the same time like the following example:select vno,sum(camt) as camt,sum(damt) as damtfrom transactwhere year = 2007group by vno and vtypeorder by vnoThanks |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-20 : 14:10:30
|
select vno,sum(camt) as camt,sum(damt) as damtfrom transactwhere year = 2007group by vno, vtypeorder by vno E 12°55'05.25"N 56°04'39.16" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-20 : 14:11:49
|
Or you can have a look in BOOKS ONLINE for the WITH ROLLUP and WITH CUBE keywords. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
issammansour
Yak Posting Veteran
51 Posts |
Posted - 2007-08-20 : 14:27:19
|
| thanks |
 |
|
|
issammansour
Yak Posting Veteran
51 Posts |
Posted - 2007-08-20 : 14:34:24
|
| is that mean I cann't add field to select side unless i add it to the group by |
 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2007-08-20 : 14:54:20
|
| Yes,Anything in your select statement that you aren't aggregating(Count, sum,min,max, etc.)has to be in the group by listJim |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-08-21 : 04:01:59
|
quote: Originally posted by issammansour is that mean I cann't add field to select side unless i add it to the group by
You need to Learn SQLRead about Group by clause in sql server help fileMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|