-
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
-
Originally Posted by bort
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
Code:
select * from (
SELECT DISTINCT parm1 FROM table1 WHERE parm1 > 10 ORDER BY parm1 )
where rownum < 2
Jeff Hunter
-
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
-
Originally Posted by gamyers
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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|