I am running a Query to return records where two items Item where both selected on thesame date.
Field names are: CPTCOD - values are '94002' and '94003' (these are teh item codes)
SCVDAT - is the date Field
The current Query is returning the following results:
When it should be returning NO records as there are no instances where both 94002 and 94003 where selected on the same date.
Create table main as
Select distinct l.*
FROM ctemp.Proc20090513 l
Where l.CPTCOD in ('94002', '94003')
AND l.SVCDAT in (SELECT l.SVCDAT From ctemp.Proc20090513 l
WHERE l.CPTCOD in ('94002', '94003')
GROUP BY l.SVCDAT HAVING COUNT(DISTINCT l.CPTCOD) > 1)