Get top 2 rows from each unique field in a column

Posted by Sai on Stack Overflow See other posts from Stack Overflow or by Sai
Published on 2014-06-09T09:21:22Z Indexed on 2014/06/09 9:24 UTC
Read the original article Hit count: 217

Filed under:
|

I have a table named tblItemResources in which I want to get the only 2 rows from each unique field in a column named effectiveDate (order by: ascending):

tblItemResources Table

|   empID   |   effectiveDate    |    Company   |    Description

|   0-123    |    2014-01-23     |   DFD Comp  |   Analyst
|   0-234    |    2014-01-23     |   ABC Comp   |  Manager
|   0-222    |    2012-02-19     |   CDC Comp  |  Janitor
|   0-213    |    2012-03-13     |   CBB Comp  |  Teller

and so on.

Any help would be much appreciated.

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server