Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to select x number of rows
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01476406
Message ID:
01476414
Views:
35
>>>>Hi,
>>>>
>>>>Is there SQL Select that can be used to select X number of records without using TOP (I find TOP is too slow). The SQL Select will have a WHERE expression but I want to return only certain number of records even if WHERE finds more.
>>>>
>>>>TIA.
>>>
>>>In SQL Server 2005 and up look up paging with ROW_NUMBER() function.
>>>
>>>It will require a derived table approach or CTE
>>>
>>>;with cte as (select ..., row_number() over (ORDER BY myOrder) as Row from myTable)
>>>
>>>select .. from cte where Row <= @SomeNumber ORDER BY Row
>>
>>Thank you. I might use this approach when having SQL Server database. But in this case I need it to work for VFP data.
>
>I see - in this case I suggest:
>
>select T.myFields from myTable T inner join (select top N PkField from myTable
> where myCondition order by myField) X on T.PkField = X.PkField
Thanks
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform