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: Specifying the maximum number of rows retrieved from a query?

Re: Specifying the maximum number of rows retrieved from a query?

From: Jim Poland <jim.poland_at_csipros.com>
Date: 1997/01/30
Message-ID: <32F0BC3E.985@csipros.com>#1/1

Shannon J. O'Brien wrote:
>
> Judy Lam wrote:
> >
> > Is there a way specify the number of rows retrieved from a query?
> >
> > I have a table that stores article information. I want to retrieve the
> > two latest articles.
>
> Try something like:
>
> SELECT A.COLX FROM DATABASE.TABLENAME A
> WHERE A.DATE > TO_DATE('DD-MON-YY')
> AND ROWNUM < 3;
>
> make sure 'DD-MON-YY' is two days ago.
> You could also be a little more general and use a where
> clause like WHERE A.DATE > (SYSDATE - 2), I guess it depends
> on you application....
>
> -Shannon
>
> --
> Shannon J. O'Brien mailto:shannon_at_compusult.nf.ca
> Programmer/Analyst http://www.compusult.nf.ca
> Compusult Ltd. Mount Pearl, NF (Developers of CIDAS)

Since you want the two latest articles, you could also try an Order By clause instead of the A.DATE > TO_DATE('DD-MON-YY') portion of the Where clause.

        Jim Received on Thu Jan 30 1997 - 00:00:00 CST

Original text of this message

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