Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: query help wanted

Re: query help wanted

From: TommCarr <tommcarr_at_aol.com>
Date: 1997/07/10
Message-ID: <19970710204101.QAA09375@ladder01.news.aol.com>#1/1

> 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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US