Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dynamic SQL and Variables
Message
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
00235209
Message ID:
00236395
Views:
16
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
Previous
Reply
Map
View

Click here to load this message in the networking platform