top n with duplicates

Joined
Sep 27, 2009
Messages
1
Reaction score
0
I'm trying to do a query for the top 3 values per group, but i want to include duplicates. I'm not very experienced with SQL...but this is what i found that pulls up the top 3.

SELECT Results.ContactID, Results.Class, Numbers.Total
FROM Results INNER JOIN Numbers ON Results.ContactID=Numbers.ContactID
WHERE (((Numbers.Total) In (Select Top 3 [Total] From Numbers Where [Class]=[Results].[Class] Order by [Total] Desc)))
ORDER BY Results.Class, Numbers.Total;

If the totals in class 1 are

100
100
99
98

I need it to pull all four, since there is a duplicate.

Any help would be appreciated.

lk96
 

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

Similar Threads


Top