How can i make select that will return only 20 first results instead of all results

How can i make select that will return only 20 first results instead of all results

Post by William dalto » Wed, 01 Sep 1999 04:00:00



for sql 7:
select top 20 <rest of select statement>

for sql 6.x
set rowcount 20
<select statement>

hth,
William


 
 
 

How can i make select that will return only 20 first results instead of all results

Post by SQL7DBA NewYor » Wed, 01 Sep 1999 04:00:00


Remember to ORDER BY DESC (or ASC) if you want the top (or bottom) 20

> for sql 7:
> select top 20 <rest of select statement>

> for sql 6.x
> set rowcount 20
> <select statement>

> hth,
> William





 
 
 

How can i make select that will return only 20 first results instead of all results

Post by X Ma » Wed, 01 Sep 1999 04:00:00


If you are using SQL 7.0 you can use the TOP command.

SELECT TOP 20 * FROM tablename