Re: Help: Flexible SQL SELECT !!
Posted in 1995
CRAIG@CHEMISTRY.CHEM.UTAH.EDU — — source: Informix-list mailing list archive (1991-1998)
John,
I, too, was thinking of your "having count..." approach. The problem
though is that in the example table a patient might have the same
diagnosis code more than once. So, your SQL would also find a patient
which has 3 or more "303.500" codes but no "339.000" or "621.100"
code. Can you think of a way to avoid this problem?
--Craig (craig@chemistry.utah.edu)
>
> Or, as another way of doing the same job:
>
> SELECT card_no
> FROM pt_code
> WHERE diag_code IN ("303.500", "339.000", "621.100")
> GROUP BY card_no
> HAVING COUNT(*) = 3;>