Click HERE to see how Saviynt Intelligence is transforming the industry. |
06/12/2024 12:51 AM
Hi All, I need a SQL query to fetch all such users -
where A is the manager of B and B is a manager of A
Please help.
06/12/2024 01:46 AM
Hi @Jaya ,
Please find the below query:
select
u.username AS 'Username',
m.username AS 'Manager Username'
from
users u,
users m
where
u.manager = m.userkey
and m.manager=u.userkey
and u.statuskey = 1
and m.statuskey = 1;
If this answers your question, please consider selecting Accept As Solution and hit Kudos
06/12/2024 02:22 AM - edited 06/12/2024 02:24 AM
Hi @Jaya ,
Use below query:
select
u.username AS 'Username',
u.owner AS 'Manager',
m.username AS 'Manager Username',
m.owner As 'Managers Manager'
from
users u,
users m
where
u.owner = m.username
and m.owner = u.username
and u.statuskey = 1
and m.statuskey = 1;
06/12/2024 03:14 AM - edited 06/12/2024 03:14 AM
@Jaya ,
Hope the SQL query helped you! Please select Accept As Solution for the reply to your original question. This article would help other engineers to find the solution soon.