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 |
dewacorp.alliances
452 Posts |
Posted - 2008-02-25 : 03:32:46
|
Hi thereI am try to get the top for each group:Field1 | Field2 | Field3 | Field41 | 200 | TEST | TEST11 | 400 | TEST2 | TEST42 | 300 | TEST | TEST32 | 600 | TEST3 | TEST10The result will be:Field1 | Field2 | Field3 | Field41 | 400 | TEST2 | TEST42 | 600 | TEST3 | TEST10Field1 is ID while Field2 is numeric.Thanks |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-02-25 : 03:53:05
|
[code]SELECT t1.*FROM Table t1INNER JOIN (SELECT Field1,MAX(Field2) AS Field2 FROM Table GROUP BY Field1) t2ON t1.Field1=t2.Field1AND t1.Field2=t2.Field2[/code] |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-02-25 : 04:07:41
|
select t1.* from table1 AS t1inner join (SELECT field1, MAX(Field2) AS f2 FROM Table1 group by field1) as x on x.field1 = t1.field1where t1.field2 = x.f2 E 12°55'05.25"N 56°04'39.16" |
 |
|
|
|
|