Subject | Re: FIRST/TOP/LIMIT/ROWNUM - Proposals |
---|---|
Author | Syarzhuk Kazachenka |
Post date | 2001-06-08T12:25:04Z |
Fred Toussi wrote:
1) Suppose I'm using a full-text search add-on and it gives me a calculated
column with estimated relevancy of the result (from 0 to 100). I might just
say "order by relevancy descending and give the user first 20 records,
because others are probably not relevant to her search":
SELECT FIRST 20 * FROM TableName ORDER BY Relevancy(UserSearchStr) DESC
2) Suppose I want to see my 10 best sales agents:
SELECT FIRST 10 LastName FROM SalesAgents ORDER BY YearlySales DESC
less in SQL. With the LIMIT you could just request a page at a time
Syarzhuk
Be healthy, stay wealthy...
Visit Belarusan Music Source - http://www.belmusic.net
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com
>It seems the only use of FIRST n or TOP n is in interactive queriesNot true. I can think of at least two more examples:
>during development. You want to see quickly if your query returns any rows
>at all, or examine the formatting of returned columns.
1) Suppose I'm using a full-text search add-on and it gives me a calculated
column with estimated relevancy of the result (from 0 to 100). I might just
say "order by relevancy descending and give the user first 20 records,
because others are probably not relevant to her search":
SELECT FIRST 20 * FROM TableName ORDER BY Relevancy(UserSearchStr) DESC
2) Suppose I want to see my 10 best sales agents:
SELECT FIRST 10 LastName FROM SalesAgents ORDER BY YearlySales DESC
>One could make use of ROWNUM as described above to issue one query toYes, but this way you would be putting more logic in the application and
>return the first row of each page that would be returned in chunks.
less in SQL. With the LIMIT you could just request a page at a time
Syarzhuk
Be healthy, stay wealthy...
Visit Belarusan Music Source - http://www.belmusic.net
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com