Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 DISTINCT AND COUNT

Author  Topic 

jhon11
Starting Member

42 Posts

Posted - 2007-11-09 : 15:51:21
Hi,

I have write down following query ..

select a.patientid, a.providerid
from PatientDrugList a
JOIN Admin..Loadinstance b on a.intLoadInstanceId = b.intLoadInstanceId
where a.MailReasonTypeId = -1
and b.SubClientId = 22
and b.StatusTypeId > 0



Now how could I get distinct patientid count and distinct providerid count


Reply soon

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-11-09 : 15:57:01
Reading Books Online makes me wanna try

select count(distinct a.patientid), count(distinct a.providerid)
from PatientDrugList as a
inner JOIN Admin..Loadinstance as b on b.intLoadInstanceId = a.intLoadInstanceId
where a.MailReasonTypeId = -1
and b.SubClientId = 22
and b.StatusTypeId > 0



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

jhon11
Starting Member

42 Posts

Posted - 2007-11-09 : 16:00:27
Thx a lot ...
Go to Top of Page
   

- Advertisement -