In SQL:1999 there's a ROW_NUMBER function, but it's not yet included (you'll have to wait until V2R5 in December).
But you can achieve the same result using
select * from table
qualify sum(1) over (order by col
rows unbounded preceding) <= 10
or
qualify rank() over (order by col) <= 10
As QUALIFY is no standard SQL you'll have to use a derived table to be ANSI compliant:
select ... from
(select ..., rank() over (order by col) AS rownum
from table) dt
where rownum <= 10
If you don't care about the order (and about ANSI SQL) use a SAMPLE clause, this will be the fastest way:
sel * from table sample 10
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.