| Author |
Topic |
|
bilencekic
Posting Yak Master
121 Posts |
Posted - 2006-06-06 : 07:55:40
|
| output=Name-------Money--------locationjack--------1000--------xxxjack--------1500---------yyyjoe--------1000---------zzzresult will be:Name-------Money--------Locationjack--------2500---------yyy >>>yyy because money is higher than other jackjoe--------1000----------zzzMS BLESS US |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-06-06 : 07:57:21
|
[code]select Name, sum(Money), max(location)from tablegroup by Name[/code] KH |
 |
|
|
bilencekic
Posting Yak Master
121 Posts |
Posted - 2006-06-06 : 08:05:19
|
| damn righti am coding the project for about 5 hours without stop and i cant think clearly sometimesthx again :DMS BLESS US |
 |
|
|
bilencekic
Posting Yak Master
121 Posts |
Posted - 2006-06-06 : 08:10:03
|
| but how max location orders itself ?it doesnt work i think.MS BLESS US |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-06-06 : 08:11:13
|
quote: Originally posted by bilencekic but how max location orders itself ?it doesnt work i think.MS BLESS US
what do you mean ? KH |
 |
|
|
bilencekic
Posting Yak Master
121 Posts |
Posted - 2006-06-06 : 08:17:49
|
| your query doesnt workwhat max(location) do?alphabetical order??because location is a textMS BLESS US |
 |
|
|
bilencekic
Posting Yak Master
121 Posts |
Posted - 2006-06-06 : 08:22:51
|
| yes it does alphabetical order i think.but in my query i want result with the location which pays the much money than othersMS BLESS US |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-06-06 : 08:28:08
|
Oh i see.select Name, sum(Money), max(location), (select top 1 location from table x where x.Name = t.Name order by Money desc)from tablegroup by Name KH |
 |
|
|
CSK
Constraint Violating Yak Guru
489 Posts |
Posted - 2006-06-06 : 08:30:06
|
| Give Me The Datatype for these thingsName-------Money--------location |
 |
|
|
bilencekic
Posting Yak Master
121 Posts |
Posted - 2006-06-06 : 08:47:59
|
| ok i have fixed it thxMS BLESS US |
 |
|
|
|