Announcing the Saviynt Knowledge Exchange unifying the Saviynt forums, documentation, training,
and more in a single search tool across platforms. Read the announcement here.

How to find out which enterprise Roles has users

Samujjal_Ghosh
New Contributor
New Contributor

Hello,

There exists many duplicate enterprise Roles in database. But there are users in some of the Roles and not in the others.

How to find out which of the roles has users and which do not?

Is there a way to generate a report that shows the roles which have users and which do not have users.

2 REPLIES 2

AmitM
Valued Contributor
Valued Contributor

Hi @Samujjal_Ghosh , see if this helps .

select role_name from roles where rolekey not in (select r.rolekey from users u
JOIN user_accounts ua ON u.userkey=ua.userkey
JOIN Accounts a ON a.accountkey=ua.accountkey
JOIN role_user_account rua ON rua.accountkey = a.accountkey
JOIN roles r ON r.rolekey=rua.rolekey where r.roletype=4) and roletype=4

Thanks, Amit

If this answers your query, Please ACCEPT SOLUTION and give KUDOS.

rushikeshvartak
All-Star
All-Star

-- Roles with users
SELECT r.rolekey, r.role_name
FROM roles r
WHERE EXISTS (
SELECT 1
FROM role_user_account rua
WHERE rua.rolekey= r.rolekey
) and roletype=4

-- Roles without users
SELECT r.rolekey, r.role_name
FROM roles r
WHERE NOT EXISTS (
SELECT 1
FROM role_user_account rua
WHERE rua.rolekey= r.rolekey
)and roletype=4


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.