Oracle query to match all values in the list among all rows in table

后端 未结 3 1954
醉话见心
醉话见心 2021-01-14 14:57

I have a table structure as under:

ID    A     B
--   ---  -----
 1    a     a1
 2    b     b1
 3    a     a2
 4    c     a1
 5    b     b2

3条回答
  •  一向
    一向 (楼主)
    2021-01-14 15:54

    Use a GROUP BY and a COUNT.

    SELECT A
    FROM yourtable
    WHERE B IN ('a1', 'a2')
    GROUP BY A
    HAVING Count(DISTINCT B) > 1
    

提交回复
热议问题