Re: Help: Flexible SQL SELECT !!
Posted in 1995
Well, how about:-
select *
from pt_code
where diag_code = "303.500"
and card_no in ( select card_no
from pt_code
where diag_code = "339.000" )
and card_no in ( select card_no
from pt_code
where diag_code = "621.100" )
or something along those lines? Basically I am just getting the lists of
all the card_nos for patients with each of the diagnoses you specify, then
taking the intersection of those lists.
- Paul
In article <1995Oct16.141608.63895@cc.usu.edu>, <sl6gs@cc.usu.edu> wrote:
>
>I have a table of patient code, every patient with a card_no(unique)
>but each card_no with multi DIAG_COD NO, I can not figure out
>how to find a patient with several DIAG_COD at same time, say
>I want to use SQL find all the patients with both DIAG_COD
>621.100 and 303.500 or with 621.100 and 303.500 and 339.000
>even more.
>
>sample table as following
>
>
>
>SQL> SELECT * FROM PT_CODE
> 2 WHERE CARD_NO = '10007';
>
>Card_no WHEN C P DIAG_COD C REP_NO
>----- --------- - - --------- - ---------
>10007 17-MAR-89 0 T 621.100 A 010007 17-MAR-89 0 T 621.100 A
>0
>10007 11-MAR-88 0 T 621.100 B 0
>10007 17-MAR-89 0 T 621.100 B 0
>10007 04-SEP-87 0 T 621.100 A 0
>10007 04-SEP-87 0 T 339.000 B 0
>10007 15-JUL-87 0 T 621.100 C 0
>10007 15-JUL-87 1 T 303.500 C 0
>10007 11-MAR-88 0 T 621.100 A 0
>10007 11-MAR-88 0 T 621.100 B 0
>10007 21-SEP-92 0 T 621.100 A 0
>10007 14-OCT-91 0 T 621.100 A 0
>
>Any suggestion?
>
>Thanks in advance.
>
>
>Wei JIang
>
> ||||||||
> | ~ ~ |
> (| @ @ |)
>----------------oOOo---(__)---oOOo------------------------
>
>
>
>
>
>