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

SQL Grouping Problem 1

Status
Not open for further replies.

archana123

Technical User
Sep 3, 2001
2
US
Hi,
I am new to this forum and I think this is a grouping question.

I have joined two tables and created a query which gives the results as follows

PatientId TypeNo
X1 1
X1 1
X1 1
X1 1
X1 2
X2 2
X2 1
X2 2
X3 1
I want to modify this query so that it will show only the PatientIds that have more than 3 duplicate(similar)Type no's .
So in this case the result would be X1 as it has Typeno 1 repeated 4 times.
Would appreciate a reply .

Thanks-
Newbee
 
add to your current statment
group by patientid, typeno having count(*) > 3
 
Thanks fluteplr for such a prompt and accurate response !!
It worked.

Newbee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top