Top 5 by specialty in subquery

  • Thread starter Thread starter Chuck W
  • Start date Start date
C

Chuck W

Hi,
I have a table called tblTop5DRG_BySpecialty which has the following fields:
Specialty (Cardiology, Internal Medicine etc.)
DRG (A number which is a type of diagnosis)
DRG title
DRGCountSpec (the number of times a DRG occured)

I want to create a query that will give me the top five DRGs by Specialty.
I created the following query but it is not working. It just gives me the
results of the table which is all DRGs by specialty. Can someone help? Chuck

SELECT tblTop5DRG_BySpecialty.Specialty, tblTop5DRG_BySpecialty.DRG,
tblTop5DRG_BySpecialty.[DRG title], tblTop5DRG_BySpecialty.DRGCountSpec INTO
tblTop5DRG_BySpecialty2
FROM tblTop5DRG_BySpecialty
WHERE (((tblTop5DRG_BySpecialty.DRG) In (SELECT TOP 5 DRG FROM
tblTop5DRG_BySpecialty AS Dupe WHERE Dupe.Specialty =
tblTop5DRG_BySpecialty.Specialty ORDER BY Dupe.DRGCountSpec DESC)));
 
Sorry my error. It is giving me ties which is why there is more than five
for many.
Chuck
 
Back
Top