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 |
DMonnik
Starting Member
2 Posts |
Posted - 2010-11-11 : 09:06:05
|
Hi guys...This is what my data looks like[tblPerson][id] [name] [value]1 john VAL1122 ben VAL4353 john VAL5234 sam VAL0935 sam VAL4556 ben VAL1157 sam VAL8858 sam VAL9999 john VAL432I need to select the single row for each name with the highest value in the value column using one T-SQL statement so that i get the following result:2 ben VAL4353 john VAL5238 sam VAL999If anyone can help with the SQL for this id appreciate it. |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-11-11 : 09:36:13
|
select * from(select *,row_number() over (partition by [name] order by replace([value],'VAL','')*1 desc as sno from table) as twhere sno=1MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|