Need Top 3 or Top n number of rows from a group of rows

  • Hi All,

    I'm trying to get the Top 3 or Top n number of rows (latest entered by date) of grouped data.  From the following query:

    SELECT Last_Name, First_Name, Task_Number, Detail_Work_Performed, Detail_Action_Date

    FROM ProjectData

    GROUP BY Last_Name, First_Name, Task_Number, Detail_Action_Date, Detail_Work_Performed

    ORDER BY Last_Name, First_Name, Task_Number, Detail_Action_Date desc

    How would I get the Top 3 latest entered rows (from Detail_Action_Date) grouped by the Task_Number?

    Sometimes I may have 10+ rows for a particulary Task_Number but only want to display the latest 3.

    Thanks for your help.

     

    Tim

  • Please don't cross post. You also have this in the 2000/2005 TSQL forum. And I posted a response there.

    http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=312785

    -SQLBill

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply