user image

Gulafsan Shaheen
Published in : 2022-03-04

How do i r etrieve users?

General

Give the following table:

employee_idgroupprobability
123group10.9
123group20.6
45group20.8
567group20.56
567group30.78
567group10.90

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_id
from table1
where group in ('group1', 'group2')
group by 1
having max(group) <> min(group) and count(employee_id) = 2
)
select *
from two_groups
join 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!

Comments

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

[solved] Unable to pull updates from git "sudo git pull"
Publish date: 2021-12-20 | Comments: 1

Tag: General

Is there any port I need to allow in google VM instances to allow SMTP?
Publish date: 2022-02-14 | Comments: 1

Tag: General

Unable to Connect AWS EC2 Instance with my subdirectory through domain registrar.
Publish date: 2022-02-25 | Comments: 2

Tag: General

Password authentication is temporarily disabled as part of a brownout.
Publish date: 2021-07-28 | Comments: 2

Tag: General

docker elastic builder exited with code 127?
Publish date: 2022-02-27 | Comments: 2

Tag: General

Convert Stored Procedure of Oracle to SQL Server
Publish date: 2022-03-02 | Comments: 1

Tag: General

what is alternative for sending mail through Gmail SMTP?
Publish date: 2022-06-08 | Comments: 1

Tag: General