Click to See Complete Forum and Search --> : SQL: How do I get just the first row of a result set?
I need to get the first row returned from a select query that looks like this:
SELECT DISTINCT parm1 FROM table1 WHERE parm1 > 10 ORDER BY parm1
Can someone please show me how to do this?
Alex
marist89
08-15-2005, 03:43 PM
I need to get the first row returned from a select query that looks like this:
SELECT DISTINCT parm1 FROM table1 WHERE parm1 > 10 ORDER BY parm1
Can someone please show me how to do this?
Alex
select * from (
SELECT DISTINCT parm1 FROM table1 WHERE parm1 > 10 ORDER BY parm1 )
where rownum < 2
gamyers
08-15-2005, 08:36 PM
SELECT min(parm1) FROM table1 WHERE parm1 > 10
would achieve (almost) the same result in this case.
Almost being, this would return null if there were no records, rather than a no rows returned/no_data_found
SELECT min(parm1) FROM table1 WHERE parm1 > 10
would achieve (almost) the same result in this case.
Almost being, this would return null if there were no records, rather than a no rows returned/no_data_found
That's exactly what I ended up doing. Thanks for the replies!