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 |
|
BitShift
Yak Posting Veteran
98 Posts |
Posted - 2007-03-27 : 09:05:46
|
in the list below, I use something like thisselect * from mytable where codenum=E4555 order by seller_levelNow, I want only the row that has the highest seller_levelbookid codenum locid s_num seller_level2323 E4555 00 R1234 53455 E4555 00 T4566 34566 E4555 00 R3355 23344 E4555 00 A3333 1 [edited to add]ok, it must be early and my brain is snoozingsince I already ordered the list, just do a top 1ie. select top 1 * ... |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-27 : 10:02:30
|
| SELECT BookID, CodeNum, LocID, s_num, Seller_LevelFROM (SELECT BookID, CodeNum, LocID, s_num, Seller_Level, ROW_NUMBER() OVER (PARTITION BY CodeNum ORDER BY Seller_Level DESC) AS RecID) AS x WHERE RecID = 1will get you the wanted record for all codenums at once.Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|
|
|