Re: Selecting only the first row from a query

From: Suman Guha <xxx_at_xxx.xxxx>
Date: 1995/11/30
Message-ID: <DIvo2y.F7y_at_txnews.amd.com>#1/1


joel_nylund_at_mail.amsinc.com (Joel Nylund) wrote:
>
>
>I need to write a sql statement to only return the first row that meets >the criteria. For example I have a table called people wit=
 h names and >phone numbers. There may be several "Joel Nylund's" in the table, I only >want the first one I find.
>
>in DB2, I can do a select first
>
>I am looking for something that will work in oracle and sybase.
>
>thanks in advance
>Joel

select min(tel_no) from phonebook
where name='&name'

or

select name, min(tel_no) from phonebook
where name like '&criteria'
group by name

(Will return only one tel no for each name)

Regards,
Suman. Received on Thu Nov 30 1995 - 00:00:00 CET

Original text of this message