RichieRich99
Programmer
Hi all,
I was asked for this query and thought it would be easy but I've struggled with it for more that two hours now.
For simplicity purposes, I have the following table:
Table: CD
Member ID, Code, Date
100, MINF03, 03/30/2005
101, MINF04, 03/30/2005
102, MINF04, 03/30/2005
102, MINF05, 03/30/2005
102, MINF04, 03/31/2005
103, MINF04, 03/31/2005
104, MINF03, 03/31/2005
The primary key is all 3 columns.
What I need is all records where Code equals MINF04 except those where there is also a code of MINF05 on the same day.
So taking the above records, my resultset would be:
Member ID, Code, Date
101, MINF04, 03/30/2005
102, MINF04, 03/31/2005
103, MINF04, 03/31/2005
I've tried a mess of options including using IN, GROUP BY, COUNT but just can't get it. Thanks in advance all.
Rick
I was asked for this query and thought it would be easy but I've struggled with it for more that two hours now.
For simplicity purposes, I have the following table:
Table: CD
Member ID, Code, Date
100, MINF03, 03/30/2005
101, MINF04, 03/30/2005
102, MINF04, 03/30/2005
102, MINF05, 03/30/2005
102, MINF04, 03/31/2005
103, MINF04, 03/31/2005
104, MINF03, 03/31/2005
The primary key is all 3 columns.
What I need is all records where Code equals MINF04 except those where there is also a code of MINF05 on the same day.
So taking the above records, my resultset would be:
Member ID, Code, Date
101, MINF04, 03/30/2005
102, MINF04, 03/31/2005
103, MINF04, 03/31/2005
I've tried a mess of options including using IN, GROUP BY, COUNT but just can't get it. Thanks in advance all.
Rick