Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dynamic SQL and Variables
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00235209
Message ID:
00236395
Vues:
17
Opps...yes, TOP was added to SQL Server in version 7.0.

In Joe Celko's SQL For Smarties, Joe has the following query for finding the Top n values (pg 327)

SELECT DISTINCT COUNT(*), a.salary
FROM employees AS a, employes AS b
WHERE a.salary <= b.salary
GROUP BY a.salary
HAVING COUNT(*) <= 3 -- control parameter

Maybe you can use this? You should be able to UNION the two queries together without needing the derived tables.

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

Click here to load this message in the networking platform