Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Selecting in blocks
Message
De
02/11/2000 08:50:16
 
 
À
02/11/2000 08:43:59
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
00437050
Message ID:
00437072
Vues:
27
Thank fgor reply

I understand the way you suggest.
But in that case is not possible to skip from page 1 to page 9
You do not kwon the lastid from page 8

Kind regards
jan


>There's no simple way to do this. But there is a straight forward method. It requires that you track the first and last sorting items and IDs for the current page of rows.
>
>Let's assume that your sorting by name. To move forward by one page:
>
>SELECT TOP 100 *
>FROM thetable
>WHERE name >= LastNameOnPage
>AND id > LastIDOnPage
>ORDER BY name, id ASC
>
>To move back one page:
>
>SELECT TOP 100 *
>FROM thetable
>WHERE name <= FirstNameOnPage
>AND id < FirstIDOnPage
>ORDER BY name, id DESC
>
>This last set will be sorted backwards so you'll have to resort it or you could do something fancy like:
>
>SELECT a.*
>FROM (
> SELECT TOP 100 *
> FROM thetable
> WHERE name <= FirstNameOnPage
> AND id < FirstIDOnPage
> ORDER BY name, id DESC) AS a
>ORDER BY name, id ASC
>
>
>This ought to get you going in the right direction.
>
>-Mike
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform