Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How do I use ROWNUM in a subquery (emulating SQL Server TOP n)
On 26 Nov 2004 02:04:03 -0800, gosta_at_midworldproduction.com (Gosta
Hulden) wrote:
>As most of you might now, the common way of emulating SQL Servers TOP
>n is to use ROWNUM
>SELECT TOP 1 fld1 FROM tbl ORDERBY fld1;
>becomes
>SELECT * FROM (SELECT fld1 FROM tbl ORDER BY fld1) WHERE ROWNUM <= 1;
>
>BUT, how can I do it in a sub query?
TOP N can be looked up in the Oracle documentation. Please avoid asking mere doc questions here.
-- Sybrand Bakker, Senior Oracle DBAReceived on Fri Nov 26 2004 - 12:13:31 CST
![]() |
![]() |