Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Paging
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Re: Paging
Divers
Thread ID:
00571415
Message ID:
00572359
Vues:
25
>Anyone have a good way to do paging as in:
>
>select {nthset(10)} * from authors
>
>Thanks,

This query will divide the pubs..authors table into 5 sections and return the id of each section. You could use these values to page for the records in each section:

select a.au_id
from authors a cross join authors b
group by a.au_id
having count(case when a.au_id <= b.au_id then 1 else null end)%(count(*)/5)=0

following this, if you knew you wanted pages with 20 records in each page, you could divide the totalcount of the table with 20 to get the number of sections that will divide the table into... then you could run a query above changing the 5 to the correct value.

Once you have the record set of the starting points of each division, you can just query the records in that range. Of course I much prefer client/side paging, bring a proxy of all the records... Even better, prompt for a filtering that will get you a limited list of recrds in the first place. If the user knows what they are looking for in a list of 10,000, then they should be able to give you the identifying values.

BOb
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform