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 |
|
nobby
Yak Posting Veteran
58 Posts |
Posted - 2007-06-11 : 16:17:16
|
| I Know how to group and i know how to return the Top nBut how do i return the top n results per group. |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-06-11 : 16:21:23
|
| search in these forums and you will find threads which asked excat same question.Dinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
nobby
Yak Posting Veteran
58 Posts |
Posted - 2007-06-11 : 18:01:12
|
| HiI have i found this example and have got it working but purely luck i think.can someone explain what each part is doing. because i don't understand exactly why this works.ELECT CustomerID FROM (SELECT CustomerID, OrderNumber, ROW_NUMBER() OVER (PARTITION BY CustomerID ORDER BY OrderDate DESC) AS RecID) AS d WHERE RecID BETWEEN 1 AND 3Thanxs |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
|
|
|
|
|