Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Group by year and count 1

Status
Not open for further replies.

din2005

Programmer
Mar 22, 2005
162
GB
Hi i have this query where i would like to show all private patients and group them by year for e.g

year patients
2006 15
2005 26
etc


so far i've got this

SELECT PATIENTS.Hospital_no, PATIENTS.firstname, PATIENTS.Surname, TREATMENT.TREATDATE, TREATMENT.PrivatePatient
FROM PATIENTS LEFT JOIN TREATMENT ON PATIENTS.Hospital_no = TREATMENT.HOSP_NO
GROUP BY PATIENTS.Hospital_no, PATIENTS.firstname, PATIENTS.Surname, TREATMENT.TREATDATE, TREATMENT.PrivatePatient
HAVING (((TREATMENT.PrivatePatient)=True))
ORDER BY TREATMENT.TREATDATE DESC;


anyway to adapt this so it shows every year how many patients treated
 
SELECT Year(TREATDATE) AS [Year], Count(*) AS Patients
FROM TREATMENT
WHERE PrivatePatient = True
GROUP BY Year(TREATDATE)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top