Re: How to limit # of rows returned by SELECT

From: Martin Wickman <martin.wickman_at_mailbox.swipnet.se>
Date: 1996/02/09
Message-ID: <4ffovr$8aa_at_sdaw04.seinf.abb.se>#1/1


gordon_at_cu.comp-unltd.com (Screemin!) wrote:

>Does anybody know if there is a way to limit the number of records
>returned by a SELECT statement? I have a large ODBC database
>where I would like to display the first 50 records that match a certain
>criteria, but I don't want the user to have to wait while the SELECT
>call processes all 7.2 quintillion records as it is a speed-critical
>application and has to happen in a couple of seconds.
 

>I tried SELECT *, COUNT(*) FROM TABLE WHERE COUNT(*) <=50
>but of course this didn't work, nor should it logically.
 

>Any help would be appreciated!

Search help for TOP

Here's a example:

SELECT TOP 25 [First Name], [Last Name]
FROM Students
WHERE [Graduation Year] = 1994
ORDER BY [Grade Point Average] DESC

--
martin.wickman_at_mailbox.swipnet.se
"Windows 95: from the guys who brought you EDLIN"
Received on Fri Feb 09 1996 - 00:00:00 CET

Original text of this message