Mulitple Categories in a query

  • Thread starter Thread starter Paid The Umpire
  • Start date Start date
P

Paid The Umpire

I have a table which contains ten different categories: A through J.

With the following of field...

Category, Score, Player1, Player2, MatchID

I'm trying to find a nice query that will give me the highest score for
each category. As well as show the players and matchID where involved.

Any ideas?
 
SELECT *
FROM [Your Table] as A
WHERE A.Score =
(SELECT MAX(Score)
FROM [Your Table] as Tmp
WHERE Tmp.Category = A.Category)

You can also do this with two queries.

Query one is a totals query that gets the Max score for each category. Save
it as qMaxCategory

Query two uses query one and the table. You join Category to Category and
Score to MaxScore
 
That is prefect.

I'm now trying to find a query like the above mentioned.

Except that I want to get the highest in each category, for a second
field "Grade".

So that I can get the highest score in each category for each grade.
Any further ideas?



John said:
SELECT *
FROM [Your Table] as A
WHERE A.Score =
(SELECT MAX(Score)
FROM [Your Table] as Tmp
WHERE Tmp.Category = A.Category)

You can also do this with two queries.

Query one is a totals query that gets the Max score for each category. Save
it as qMaxCategory

Query two uses query one and the table. You join Category to Category and
Score to MaxScore


Paid The Umpire said:
I have a table which contains ten different categories: A through J.

With the following of field...

Category, Score, Player1, Player2, MatchID

I'm trying to find a nice query that will give me the highest score for
each category. As well as show the players and matchID where involved.

Any ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top