One table, 4 columns: index, date, a and b.
Let's say I have the folling rows:
0, 20051201, 4, 1
1, 20051202, 4, 1
2, 20051203, 4, 1
3, 20051204, 4, 1
4, 20051203, 3, 2
5, 20051204, 3, 2
6, 20051208, 3, 2
7, 20051204, 2, 1
8, 20051207, 2, 2
I need to delete the oldest rows which have the same a and b - and leave the 2 newest rows untouched. So a delete-statement should remove row 0, 1 and 4. I'm using postgres. Any idea?
Thanks in advance!
Let's say I have the folling rows:
0, 20051201, 4, 1
1, 20051202, 4, 1
2, 20051203, 4, 1
3, 20051204, 4, 1
4, 20051203, 3, 2
5, 20051204, 3, 2
6, 20051208, 3, 2
7, 20051204, 2, 1
8, 20051207, 2, 2
I need to delete the oldest rows which have the same a and b - and leave the 2 newest rows untouched. So a delete-statement should remove row 0, 1 and 4. I'm using postgres. Any idea?
Thanks in advance!