Hi all,

Firstly, i am a Java program Developer for 2 years and honestly speaking i had very few occessions where i had to write complex queries. Now following the first stint with DB2, i have a requirement where i have to write a query for deletion of every record except last two.If i ellaborate it further with an example it may closely look like this-

table JOBS_RECORDS

Job_group Job_id Created_time
1 1 12 Feb,2012,11:12:13 pm
1 2 12 Feb,2013,11:12:13 pm
1 3 12 Feb,2014,11:12:13 pm
1 4 12 Feb,2015,11:12:13 pm
1 5 12 Feb,2016,11:12:13 pm
2 1 12 Feb,2012,11:12:13 pm
2 2 12 Feb,2013,11:12:13 pm
2 3 12 Feb,2014,11:12:13 pm
2 4 12 Feb,2015,11:12:13 pm


so i will have to retain

1 4
1 5
2 3
2 4

Rest i will have to delete.

I googled, and found some queries. But i really want to understand the logic and also want to know the performance aspects of those queries