Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: query help wanted
> I need some help/suggestions for a query that will keep the 200 most
current rows
> for each customer and delete the rest (older) ones.
>
> Table contains 2 columns - custid, access_date
>
> For each custid, keep the 1st 200 most current rows, rest to be deleted.
Simple:
delete from cust
where rowid not in(
select rowid from cust
where rownum <= 200
order by access_date desc);
Tomm Carr
In giving freedom to the slave we assure freedom to the free,
honorable alike in what we give and what we preserve.
---- Abraham ByGod Lincoln
Received on Thu Jul 10 1997 - 00:00:00 CDT
![]() |
![]() |