I am having trouble running a query. I am trying to join 3 tables to displays the top 10 medications by the amount of times that were prescribed in a single year.
When I run it as is I get an error message about something is wrong in either the aggregate or the Select.
This is my query:
Select Count(MED_ID), MEDICATIONS.MEDICATION_NAME, ENCOUNTER.OBSDATE
From MEDICATIONS
Inner JOIN ENC_MEDICATIONS On ENC_MEDICATIONS.MED_ID = MEDICATIONS.MED_ID
Inner JOIN ENCOUNTER On ENC_MEDICATIONS.ENC_ID = ENCOUNTER.ENC_ID
WHERE OBSDATE Between '01/01/2011' And '12/31/2011'
GROUP BY (MEDICATION_NAME)
ORDER BY COUNT(MED_ID) DESC
Where am I going wrong in the Joins to get the result I am trying to display.
Thanks! - Ann
