I have a table in the database with records as shown below :
Id | EmpName | LeaveDate | createdDate
1 | Govind | 2014-04-02 00:00:00.000 | 2014-04-02
2 | Aravind | 2014-04-03 00:00:00.000 | 2014-04-05
3 | Govind | 2014-04-04 00:00:00.000 | 2014-04-10
4 | Amar | 2014-04-05 00:00:00.000 | 2014-04-11
6 | Aravind | 2014-04-06 00:00:00.000 | 2014-04-16
7 | Govind | 2014-04-07 00:00:00.000 | 2014-04-16
8 | Aravind | 2014-04-08 00:00:00.000 | 2014-04-16
9 | Amar | 2014-04-09 00:00:00.000 | 2014-04-16
10 | Aravind | 2014-04-10 00:00:00.000 | 2014-04-16
11 | Govind | 2014-04-11 00:00:00.000 | 2014-04-16
12 | Aravind | 2014-04-12 00:00:00.000 | 2014-04-16
13 | Amar | 2014-04-13 00:00:00.000 | 2014-04-16
14 | Aravind | 2014-04-14 00:00:00.000 | 2014-04-16
Now, I want display the last two records of the all employees
Sample output:
Id | EmpName | LeaveDate | createdDate
11 | Govind | 2014-04-11 00:00:00.000 | 2014-04-16
7 | Govind | 2014-04-07 00:00:00.000 | 2014-04-16
14 | Aravind | 2014-04-14 00:00:00.000 | 2014-04-16
12 | Aravind | 2014-04-12 00:00:00.000 | 2014-04-16
13 | Amar | 2014-04-13 00:00:00.000 | 2014-04-16
9 | Amar | 2014-04-09 00:00:00.000 | 2014-04-16
Am using JPA, difficult to compose the query for following requirement. Any one help me