原始表数据
select
DTRQLFR.DETERMINATION_ID_FK, DTRQLFR.QUALIFIER_ID_FK, DTRQLFR.QUALIFIER_OPTION_ID_FK
from IC_DTRMN_QLFR_XREF DTRQLFR
WHERE
(DTRQLFR.QUALIFIER_ID_FK, DTRQLFR.QUALIFIER_OPTION_ID_FK) IN ((1,1), (2,3), (3,6));
查询结果
我的要求是需要在数据集上应用和操作,如下所示
((1,1) AND (2,3) AND (3,6)) ==> need to find DETERMINATION_ID_FK as 1
based on (DTRQLFR.QUALIFIER_ID_FK, DTRQLFR.QUALIFIER_OPTION_ID_FK) values
预期结果
答案 0 :(得分:2)
我认为您正在尝试找到包含所有给定集合的dtrqlfr.determination_id_fk
。这样的事情可以奏效:
select
DTRQLFR.DETERMINATION_ID_FK
from IC_DTRMN_QLFR_XREF DTRQLFR
where
(DTRQLFR.QUALIFIER_ID_FK, DTRQLFR.QUALIFIER_OPTION_ID_FK) IN ((1,1), (2,3), (3,6))
group by DTRQLFR.DETERMINATION_ID_FK
having count(*) = 3 -- where 3 is equal to the number of sets
;