Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How does Top nnn work in SQL Select?
Message
From
25/05/1999 19:56:41
 
 
To
24/05/1999 16:09:03
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00222192
Message ID:
00222723
Views:
19
>>Not a peculiar question at all. In fact, VFP selects all the records then dumps all but the top 99. So it's not a very efficient method, it's just a bit more convenient than having to pull out the top 99 yourself.
>>
>>>Hi All!
>>>
>>>I have a peculiar question regarding TOP clause in SQL Select.
>>>How does VFP perform this task: (let's say I want the top 99 records)
>>>1. VFP fetches all appropiate records, orders them and deletes unwanted ones on the end above 99, or
>>>2. VFP uses the index of ordered field in base table, and fetches only the records that fall under 99 according to the index.
>>>
>>>TIA
>>>
>>>BB
>
>Thanks Josh!
>
>That's what I was afraid of!!!
>
>BB

Not exactly true. If you have more than 99 records that match your criteria, but are at the same level as the 99 you requested, you'll get all of them.

SELECT TOP 5 idkey,cntr FROM mydata WHERE cntr=0 ORDER BY cntr

may return more than 5 records...
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform