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
 Unique Memebers Count

Author  Topic 

werhardt
Constraint Violating Yak Guru

270 Posts

Posted - 2009-07-31 : 07:41:24
Not sure if you can help me or not. I am trying to find the unique member ids. It works if I use this statment below..

Select Distinct
Count (Distinct MemberID), MemberID--ClientName
from VW_Member_Count_FamilyID_ClientRecord
Group by MemberID


The only thin is my client want to have the memberID, and the Patient First and last name associated with it. So, if I put this in there, it brings up two patients under the same memberID because the firstname and last name are different. How can I just pull one MemberID and still have the PatientLast/PatientFirst in the grouping?

Select Distinct
Count (Distinct MemberID), MemberID, PATIENTLASTNAME,PATIENTFIRSTNAME
from VW_Member_Count_FamilyID_ClientRecord
Group by MemberID,PATIENTLASTNAME--PATIENTFIRSTNAME
Order by MemberID

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2009-07-31 : 08:47:49
This sounds like a job for Crystal Reports!

http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx
How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-07-31 : 08:54:00
Yes. If you use Reporting tool, make use of it's Suppress if duplicated feature

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

werhardt
Constraint Violating Yak Guru

270 Posts

Posted - 2009-07-31 : 09:00:09
I am actually going to be using Microsoft Visual Studios
quote:
Originally posted by madhivanan

Yes. If you use Reporting tool, make use of it's Suppress if duplicated feature

Madhivanan

Failing to plan is Planning to fail

Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-07-31 : 13:07:24
1. What version of SQL are you using?
2. When there are mutiple rows for teh same ID, which one do you want?
3. http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page
   

- Advertisement -