By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,612 Members | 909 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,612 IT Pros & Developers. It's quick & easy.

distinct id

P: 2
I have a table called patients with patientsid and doctorid in it. I am trying to run a query using distinct count to find how many different doctors have patients assigned to them.

There are 5 doctors total. 2 doctors have 2 patients each, 2 have 1 patient each , and 1 has none. Every way I have tried the answer comes up as 6 because the doctors with 2 patients are being counted twice. The answer should be 4.

I believe I am using the distinct command in the wrong place.

Any help would be appreciated.
May 22 '07 #1
Share this Question
Share on Google+
1 Reply

puppydogbuddy
Expert 100+
P: 1,923
I have a table called patients with patientsid and doctorid in it. I am trying to run a query using distinct count to find how many different doctors have patients assigned to them.

There are 5 doctors total. 2 doctors have 2 patients each, 2 have 1 patient each , and 1 has none. Every way I have tried the answer comes up as 6 because the doctors with 2 patients are being counted twice. The answer should be 4.

I believe I am using the distinct command in the wrong place.

Any help would be appreciated.
You need to post your query, but try distinct this way:
Select Distinct doctorid, patientid, ...................
May 22 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.