D
Desert Moon
I need some help with an existing query that isn't working quite
right.
I have a database for scoring show cats. Each ring (no, we don't walk
the cats around as the dog folks do) and each cat's 50 highest-scoring
rings are scored for awards.
So I need a query to add up the top 50 rings for each cat and then
rank the results in descending order to tabulate the standings. The
query I have works except that if a cat has several rings all with the
same value, they are all added in; e. g., cat's rings are
Ring# Score
49 82
50 71
51 71
52 71
53 71
I need Access to keep rings 49 amd 50 but drop 51 through 53. Right
now I'm getting the top 53 rings instead of just the top 50!
SELECT Cats.CatName, Sum(qryCats_Rings.RegionalPts) AS Score
FROM qryCats_Rings INNER JOIN Cats ON qryCats_Rings.CatID = Cats.CatID
WHERE (((qryCats_Rings.RegionalPts) In (SELECT top 50 RegionalPts from
qryCats_Rings
WHERE Cats.CatID=qryCats_Rings.CatID and Cats.Class="HHP"
ORDER BY RegionalPts DESC)))
GROUP BY Cats.CatName, Cats.Region
ORDER BY Sum(qryCats_Rings.RegionalPts) DESC;
That's my SQL. "RegionalPts" is the ring score, a not-very-elegant
nested Iif formula based on info in three other fields.
Thanks in advance,
Cheryl Leigh
right.
I have a database for scoring show cats. Each ring (no, we don't walk
the cats around as the dog folks do) and each cat's 50 highest-scoring
rings are scored for awards.
So I need a query to add up the top 50 rings for each cat and then
rank the results in descending order to tabulate the standings. The
query I have works except that if a cat has several rings all with the
same value, they are all added in; e. g., cat's rings are
Ring# Score
49 82
50 71
51 71
52 71
53 71
I need Access to keep rings 49 amd 50 but drop 51 through 53. Right
now I'm getting the top 53 rings instead of just the top 50!
SELECT Cats.CatName, Sum(qryCats_Rings.RegionalPts) AS Score
FROM qryCats_Rings INNER JOIN Cats ON qryCats_Rings.CatID = Cats.CatID
WHERE (((qryCats_Rings.RegionalPts) In (SELECT top 50 RegionalPts from
qryCats_Rings
WHERE Cats.CatID=qryCats_Rings.CatID and Cats.Class="HHP"
ORDER BY RegionalPts DESC)))
GROUP BY Cats.CatName, Cats.Region
ORDER BY Sum(qryCats_Rings.RegionalPts) DESC;
That's my SQL. "RegionalPts" is the ring score, a not-very-elegant
nested Iif formula based on info in three other fields.
Thanks in advance,
Cheryl Leigh