Saviynt unveils its cutting-edge Intelligence Suite products to revolutionize Identity Security!
Click HERE to see how Saviynt Intelligence is transforming the industry.
Saviynt Copilot Icon

Sql query required

Jaya
Regular Contributor II
Regular Contributor II

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.

 

Thanks
Jaya Karothia
3 REPLIES 3

PremMahadikar
All-Star
All-Star

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

pmahalle
All-Star
All-Star

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;

Pandharinath Mahalle(Paddy)
If this reply helps your question, please consider selecting Accept As Solution and hit Kudos 🙂

PremMahadikar
All-Star
All-Star

@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.