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.
| Author |
Topic |
|
JeffS23
Posting Yak Master
212 Posts |
Posted - 2007-12-26 : 14:08:31
|
| I am creating a query which will show patients that are enrolled in more than one program, but I need to exclude those patients that enrolled more than once in the same program. Here's part of the code:SELECT member_id, service_id FROM pat_prg_info ppi This query produces results like the following:member_id service_id1001 11001 21003 91003 91004 21004 9I would like to exclude 1003, since this member_id is enrolled twice in service_id 9. How can I accomplish this? |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-12-26 : 14:25:15
|
| SELECT member_id, service_id FROM pat_prg_info ppi GROUP BY member_id, service_idHAVING COUNT(*) = 1Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
|
|
|