SELECT
person_id
FROM
yourTable
WHERE
department = 'a'
OR department = 'b'
GROUP BY
person_id
HAVING
COUNT(DISTINCT department) = 2
Obs:DISTINCT behövs bara om en person kan vara medlem i samma avdelning mer än en gång.
SELECT
person_id
FROM
yourTable
WHERE
department = 'a'
OR department = 'b'
GROUP BY
person_id
HAVING
COUNT(DISTINCT department) = 2
Obs:DISTINCT behövs bara om en person kan vara medlem i samma avdelning mer än en gång.