0

結合またはその他の方法を使用して、次のクエリを可能な限り単純化する必要があります...

select polid
  from polver
  where idmkey = 'idm3'
    and polid in ( select polid
                     from polver
                     where idmkey = 'idm2'
                       and polid in ( select polid
                                        from polver
                                        where idmkey='idm1' ) );
4

2 に答える 2

3

次の方法でグループを使用できます。

select  polid
from    polver
group by
        polid
having  max(case when idmkey = 'idm1' then 1 end) = 1
        and max(case when idmkey = 'idm2' then 1 end) = 1
        and max(case when idmkey = 'idm3' then 1 end) = 1
于 2012-08-04T14:05:54.927 に答える
3
select polid from polver
where idmkey in ('idm1', 'idm2', 'idm3') 
group by polid
having count(distinct idmkey) = 3
于 2012-08-04T14:06:56.843 に答える