Gulafsan Shaheen
Published in : 2022-03-04

How do i r etrieve users?


Give the following table:


I need to extract users who are in group 1 and 2, which means I only need to retrieve user 123. My query goes like the following:

with two_groups as (select employee_idfrom table1where group in ('group1', 'group2')group by 1having max(group) <> min(group) and count(employee_id) = 2)select *from two_groupsjoin table1 using (employee_id)

The reason that I am joining it back to the table1 is because I could not add the group and probability columns as a field in the "two_groups" subquery because I didn't want to group by them.

What Can I do to just extract the users being in just exactly two groups?

Thank you!


There is no comments yet

Leave a comment

Join us

Join our community and get the chance to solve your code issues & share your opinion with us

Sign up Now

Related posts

How to checkout to new created branch on bitbucket
Publish date: 2022-03-03 | Comments: 1

Tag: General

git issue, fatal error: your current branch appears to be broken
Publish date: 2022-03-01 | Comments: 2

Tag: General

Help with sliding an image from the top of a stack
Publish date: 2022-02-12 | Comments: 1

Tag: General

Is it possible to git commit files without adding a message or comments?
Publish date: 2022-03-02 | Comments: 2

Tag: General

Keycloak db query in source codes [closed]
Publish date: 2022-03-05 | Comments: 0

Tag: General

Searching for free live chat service
Publish date: 2022-02-11 | Comments: 2

Tag: General