Hi all ... could be simple but I'm banging my head against a wall here. I have a table with 2 columns & many rows. It looks like ;
org_no date
-----------------------
111 01-01-1999
111 12-08-1998
111 03-03-1998
222 13-05-2000
222 22-09-1999
..
..
..
etc....
No limit on number of rows per organisation.
What I want to do is delete all but the most recent 6 rows for each organisation. I've been playing around with order by/group by/having, etc. I also know it can be done quite simply with cursors, but is there another way with standard SQL?
Any help/advice is much appreciated. (I'm using Sybase but any pseudo-SQL will do).
Greg. [sig][/sig]
org_no date
-----------------------
111 01-01-1999
111 12-08-1998
111 03-03-1998
222 13-05-2000
222 22-09-1999
..
..
..
etc....
No limit on number of rows per organisation.
What I want to do is delete all but the most recent 6 rows for each organisation. I've been playing around with order by/group by/having, etc. I also know it can be done quite simply with cursors, but is there another way with standard SQL?
Any help/advice is much appreciated. (I'm using Sybase but any pseudo-SQL will do).
Greg. [sig][/sig]