Top X Query

DianaW

Registered User.
Local time
Today, 08:34
Joined
Sep 11, 2007
Messages
29
Hi there,

the following query retrieves the Top 20 values of "Mcap":

Code:
SELECT TOP 20 D.Mcap
FROM Data as D
WHERE ...
ORDER BY Mcap DESC

How do I have to modify the code so that I get the sum of the Top 20 values of Mcap?

Thank you for your help...

Diana
 
Hi Brian,

thanks for your reply. I'm not sure what you mean... Could you please give me an example?

Diana

Use another query to take in the results.

Brian
 
Say your query is query1
Then
Select sum(mcap) as SumofMcap
From Query1


brian
 
Or use a subquery

Select Sum(Mcap) as SumofMcap
From (Your query...
..);

Brian
 

Users who are viewing this thread

Back
Top Bottom