Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SELECT TOP
Message
De
24/02/2001 09:11:33
 
 
À
23/02/2001 17:59:43
Greg Coopman
Gc Systems Corporation
Hollywood, Floride, États-Unis
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Divers
Thread ID:
00479100
Message ID:
00479202
Vues:
36
There really not a good solution to this issue because SQL does not imply a position relationship between rows. This query works but has some issues:
SELECT TOP 50
	Customerid
FROM (
	SELECT TOP 100
		Customerid,
		CompanyName
	FROM
		Customers
	ORDER BY 
		CompanyName ASC, 
		customerid) AS a
ORDER BY 
	CompanyName DESC, 
	customerid
The issues are straight forward:
1 - The TOP clause is not parameterizable. You'll have to use Dynamic SQL or an ad-hoc query.
2 - In order to get the last set of rows, the derived table will have to calculate the entire table. If you're going to really use this query in a production environment, you'll have to figure out a way to reverse everything when you page past half the file.

-Mike
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform