Re: SQL question (retriveing n number of rows)
Posted in 1996
Toby Denbow wrote:
>
> How do I retrieve a set number of rows in a SQL select.
>
> If my select is something like:
> select * from tab1 where x = y.>
> how do I retrieve only the first 50 rows.
>
> -Toby Denbow
> tdenbow@mathworks.com
Off the top of my head so I don't know if this will work:
create a temp table (or temporarily create a permanent table)
with a serial column as the first field, the other fields like
tab1 above.
insert into tmp_tab select 0,tab1.* from tab1 where ...
(if you need an order by i don't know if its allowed here)
select <fields you want> from tmp_tab where serial_field<50
If you're using 4gl, you'd just declare a cursor and fetch 50 times.
--
Sincerly,
Doug Wilson(dougw@amgen.com)
*** The opinions expressed here are my own and not neccessarily ***
*** anyone elses ****
*** Disclaimer: These are the opinions of the poster not Amgen Inc.***