Dear Mark:
And thanks for the endorsement, John. Always good to hear from you!
OK, here's me thinking my way through this, out loud.
First, the query is obviously not complete as posted. Also, it
contains references to two tables not in evidence - no FROM clause.
But, based on what I can see here, I'll try to construct the ranking
based on the query shown rather than directly on the tables. That
works, too.
SELECT TOP 10 SMGR, REGION, SumOfYRDS_2004, SumOfSAME_YRDS_2003,
[% Increase],
(SELECT COUNT(*) + 1 FROM YourQuery Q1
WHERE Q1.[% Increase] > Q.[% Increase]) AS Rank
FROM YourQuery Q
ORDER BY [% Increase] DESC
Now, I've had to interpret some of what you said in what I thought was
a reasonable, but not necessarily correct fashion, especially what you
wanted for TOP 10. Are we at all close?
Now, I'd be glad to transmit what little I know about these subqueries
to John and others, but then I wuoldn't have a specialty of my own! A
guy has to have SOMETHING for which he's known!
But, when I'm needed in a particular thread, you MVPs could drop me a
line. I don't often spend enough time looking at threads that are
already underway to catch this. Just lucky this time. Well lucky if
you assume I've been helpful.
Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts
I have this query below that I use to calculate the percent increase for
sales by manager, by region. I want to take the percentages and rank them
in order for the TOP 10. How do I do this based on the highest % Increase.
SELECT
[Yards].SMGR,
[Yards].REGION,
Sum([Super Report].YRDS_2004) AS SumOfYRDS_2004,
Sum([Super Report].SAME_YRDS_2003) AS SumOfSAME_YRDS_2003,
([SumOfYRDS_2004]/[SumOfSAME_YRDS_2003]) AS [% Increase]