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

show records with multiple treatments

Status
Not open for further replies.

din2005

Programmer
Mar 22, 2005
162
GB
Hi a table treatment how do i show records with patient who had more than 1 treatment... i.e anyone who has same hospital no more than once e.g

hospno name treatdate
dd1234 andrew 12/12/2000
dd1234 andrew 12/12/2000
cc3246 david 20/01/1995
cc3246 david 20/01/1995

etc

is there a criteria i can use in the query to show records with more than one record using same hosp no?
 
Something like this ?
SELECT A.hospno, A.name, A.treatdate
FROM yourTable As A INNER JOIN (
SELECT hospno, name FROM yourTable GROUP BY hospno, name HAVING Count(*)>1
) As B ON A.hospno=B.hospno AND A.name=B.name

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
thanks guys

how would it look with this


SELECT TREATMENT.Hospital_no, PATIENTS.Surname, PATIENTS.firstname, TREATMENT.TREATDATE, TREATMENT.PATHOLOGY
FROM PATIENTS INNER JOIN TREATMENT ON PATIENTS.Hospital_no = TREATMENT.HOSP_NO
GROUP BY TREATMENT.Hospital_no, PATIENTS.Surname, PATIENTS.firstname, TREATMENT.TREATDATE, TREATMENT.PATHOLOGY
HAVING (((TREATMENT.PATHOLOGY)="trigeminal neuralgia"));


sorry queries/sql not my strongest points still learning...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top