SSISO Community

시소당

9. 한번이라도 상품을 구매한 고객을 구하라.

Select  distinct  a.cust_name,  b.br_name
From  customer  a,  branch  b,  sale  c
Where  a.br_no  =  b.br_no  and  a.cust_no  =  c.cust_no
And    c.saledate  like  ‘1995%’;

<개선안1>
select  a.cust_name,  b.br_name
from  customer  a,  branch  b
where  a.br_no  =  b.br_no
and  a.cust_no  in  (select  cust_no  
                                                          from  sale
                                                          where  saledate  like  ‘1995%’);  

<개선안2>
select  a.cust_name,  br_name
from  customer  a,  branch  b
where  exits  (select  ‘x’  
                                            from  sale  c  
                                        where  a.cust_no  =  c.c  

1051 view

4.0 stars