2 added 1 character in body
source | link

You can use bool_or for this.

SELECT user_id
FROM users
GROUP BY user_id
HAVING bool_or(activity_id IN (1,2))  -- assumes '1, 2' mean '1 OR 2'
  AND NOT bool_or(activity_id IN (3));

You can use bool_or for this.

SELECT user_id
FROM users
GROUP BY user_id
HAVING bool_or(activity_id IN (1,2))  -- assumes '1, 2' mean '1 OR 2'
  AND NOT bool_or(activity_id IN (3))

You can use bool_or for this.

SELECT user_id
FROM users
GROUP BY user_id
HAVING bool_or(activity_id IN (1,2))  -- assumes '1, 2' mean '1 OR 2'
  AND NOT bool_or(activity_id IN (3));
1
source | link

You can use bool_or for this.

SELECT user_id
FROM users
GROUP BY user_id
HAVING bool_or(activity_id IN (1,2))  -- assumes '1, 2' mean '1 OR 2'
  AND NOT bool_or(activity_id IN (3))