Re: Bring Back Only One Record From A Query

From: DanHW <danhw_at_aol.com>
Date: 24 Nov 1999 01:27:23 GMT
Message-ID: <19991123202723.03589.00000055_at_ng-cc1.aol.com>


>Howdy,
>
>I am trying to figure out a way of bringing back only the first record
>of a query without having to use a cursor.
>
>I can't use the Rownum keyword because the sort by is the most
>important part of the query.
>
>Does anyone have any ideas?
>
>Thanks,
>
>Anton
>
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.
>
>
>
You have "select ... from ... where...order by col1"

Change the where clause, adding an additional clause:

and col1 = (select max(col1) from <same tables, where clause etc from main query)

This will return exactly one row as long as only one row has the max value. If more than one row has the same value, you will need to do something based on rowid or a unique key...

and to_char(col1)||to_char(uniquekey) =
(select max(to_char(col1)||to_char(uniquekey) from...)

I think you get the idea

Dan Received on Wed Nov 24 1999 - 02:27:23 CET

Original text of this message