Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to select x number of rows
Message
 
 
À
12/08/2010 18:59:19
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01476406
Message ID:
01476410
Vues:
56
>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
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform