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

report required for active and inactive with the query added

Growit
New Contributor
New Contributor

below query need change to get the active and inactive users in that particular application

SELECT ep.endpointname,
Date_format(a.created_on, '%Y.%m') AS Month,
Count(DISTINCT ua.userkey) AS user_count
FROM user_accounts ua
JOIN accounts a
ON ua.accountkey = a.accountkey
JOIN endpoints ep
ON ep.endpointkey = a.endpointkey
WHERE ep.endpointname = 'MyLearning_External'
GROUP BY Date_format(a.created_on, '%Y.%m')
ORDER BY month ASC

from last april 2023 to this month 2024 users who accessed and created in the application

output

Growit_0-1725975936547.png

 

above has the data and required the users who are active and inactive.

Could you please split it in two columns with information how many was active and how many was inactive

4 REPLIES 4

rushikeshvartak
All-Star
All-Star

SELECT ep.endpointname,
Date_format(a.created_on, '%Y.%m') AS Month,
Count(DISTINCT ua.userkey) AS user_count,
a.Status
FROM user_accounts ua
JOIN accounts a
ON ua.accountkey = a.accountkey
JOIN endpoints ep
ON ep.endpointkey = a.endpointkey
WHERE ep.endpointname = 'ActiveDirectory_Offshore'
GROUP BY Date_format(a.created_on, '%Y.%m'),a.status
ORDER BY month ASC

rushikeshvartak_0-1725976349934.png

 


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

Amit_Malik
Valued Contributor II
Valued Contributor II

This one will give it in two rows

SELECT ep.endpointname,
Date_format(a.created_on, '%Y.%m') AS Month,
Count(DISTINCT ua.userkey) AS user_count, a.status
FROM user_accounts ua
JOIN accounts a
ON ua.accountkey = a.accountkey
JOIN endpoints ep
ON ep.endpointkey = a.endpointkey
WHERE ep.endpointname = 'MyLearning_External'
GROUP BY Date_format(a.created_on, '%Y.%m'),a.status
ORDER BY month ASC

 

Something like this will give you in two columns 

select a.endpointname,a.month_a,a.user_count_a,b.user_count_b from (SELECT ep.endpointname,
Date_format(a.created_on, '%Y.%m') AS Month_a,
Count(DISTINCT ua.userkey) AS user_count_a
FROM user_accounts ua
JOIN accounts a
ON ua.accountkey = a.accountkey
JOIN endpoints ep
ON ep.endpointkey = a.endpointkey
WHERE ep.endpointname = 'Delinea Preprod' and a.created_on is not null
GROUP BY Date_format(a.created_on, '%Y.%m')) a
LEFT JOIN
(SELECT ep.endpointname,
Date_format(a.created_on, '%Y.%m') AS Month_b,
Count(DISTINCT ua.userkey) AS user_count_b
FROM user_accounts ua
JOIN accounts a
ON ua.accountkey = a.accountkey
JOIN endpoints ep
ON ep.endpointkey = a.endpointkey
WHERE ep.endpointname = 'Delinea Preprod' and a.created_on is not null and a.status in ('1','manually provisioned')
GROUP BY Date_format(a.created_on, '%Y.%m')) b
ON a.endpointname=b.endpointname and a.Month_a=b.Month_b

Amit_Malik_2-1725979037928.png

 

 

 

Kind Regards,
Amit Malik
If this helped you move forward, please click on the "Kudos" button.
If this answers your query, please select "Accept As Solution".

Growit
New Contributor
New Contributor

need to show wether is is active and inactive , data should show active or inactive

Amit_Malik
Valued Contributor II
Valued Contributor II

select a.endpointname,a.month_a,a.user_count_a as Toatal_Count,b.user_count_b as Active_Count, a.user_count_a-b.user_count_b as Non_Active from (SELECT ep.endpointname,
Date_format(a.created_on, '%Y.%m') AS Month_a,
Count(DISTINCT ua.userkey) AS user_count_a
FROM user_accounts ua
JOIN accounts a
ON ua.accountkey = a.accountkey
JOIN endpoints ep
ON ep.endpointkey = a.endpointkey
WHERE ep.endpointname = 'CRB_AD_DEV' and a.created_on is not null
GROUP BY Date_format(a.created_on, '%Y.%m')) a
LEFT JOIN
(SELECT ep.endpointname,
Date_format(a.created_on, '%Y.%m') AS Month_b,
Count(DISTINCT ua.userkey) AS user_count_b
FROM user_accounts ua
JOIN accounts a
ON ua.accountkey = a.accountkey
JOIN endpoints ep
ON ep.endpointkey = a.endpointkey
WHERE ep.endpointname = 'Your Endpoint' and a.created_on is not null and a.status in ('1','manually provisioned')
GROUP BY Date_format(a.created_on, '%Y.%m')) b
ON a.endpointname=b.endpointname and a.Month_a=b.Month_b
where user_count_b is not null

Amit_Malik_0-1725981013296.png

 

 

Kind Regards,
Amit Malik
If this helped you move forward, please click on the "Kudos" button.
If this answers your query, please select "Accept As Solution".