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: newbie question about rownum

Re: newbie question about rownum

From: steve lancour <steve_at_lancour.tcimet.net>
Date: Tue, 25 Aug 1998 21:41:05 -0400
Message-ID: <35E367B1.5E969BE1@lancour.tcimet.net>


Rod,

        Thanks for the reply. I think I failed in describing accurately what I'm trying to do. I need to select any column or columns from any table, using any column or combination of columns in both WHERE and ORDER-BY clauses, and return only the first record from the result set. I might say SELECT FIRSTNAME, LASTNAME, DEPARTMENT FROM EMPLOYEES WHERE FIRSTNAME = "BOB" AND AGE > 30 ORDER BY LASTNAME;. I'm only interested in the first person on the list (first in this example defined as the "bob" who is older than 30 and whose last name appears first on an alphabetical listing). Similarly, I might say SELECT FIRSTNAME, LASTNAME, DEPARTMENT FROM EMPLOYEES WHERE FIRSTNAME = "BOB" AND AGE > 30 ORDER BY AGE; and again, only want the first record, this time defining "first" as the youngest "bob" older than 30.

        Thanks again for your time.

Rod Stewart wrote:
>
> Steve,
>
> If all you are trying to do is get the first name alphabetically you can use
> the min function. eg,
>
> SELECT MIN(name) FROM Employees;
>
> Regards
>
> Rod Stewart
>
> steve lancour wrote in message <35E351B4.E36B04B0_at_lancour.tcimet.net>...
> > I'm trying to query an Oracle table using an order by clause, but am
> >only interested in the first row returned by the query. For example, I
> >have a table called EMPLOYEES with a column called NAME and want only
> >the first record in alphabetical order by name.
> >

--
Steve Lancour Received on Tue Aug 25 1998 - 20:41:05 CDT

Original text of this message

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