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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need sql statement

Status
Not open for further replies.

s4dadmin

Programmer
Apr 27, 2003
107
US
I have a table called patient which holds patient information like their name and address. I have another called [patient status] which holds diagnosis, patient id, and diet. And another called admission which holds the patient id, and date_admit. I am using MS Access 2000. I need to make 2 reports.

1. Breakdown by numbers of patients classified by type of diets.

2. Display a list of all patients that were treated for the same diagnosid during the past 30 days.

Can anyone help?
 
1.
SELECT COUNT(patientid) FROM [patient status] GROUP BY diet ORDER BY COUNT(patientid) DESC

2.
--replace the 7 to select diagnosid
SELECT patientid, name FROM patient p INNER JOIN [patient status] ps ON p.patientid = ps.patientid INNER JOIN admission a ON p.patientid = a.patientid WHERE date_admit > now()-30 AND diagnosid = 7
 
Thanks Jonax, the number 2 sql statement is perfect, but I still need help with number 1. I need to show the name of the diet, your sql statement does not show that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top