Query Account to Entitlement
SELECT EP.displayname AS APPLICATION,
ACC.NAME AS ACCOUNTNAME,
EV.entitlement_value AS ENTITLEMENTNAME,
U.username AS USERID,
Concat(U.firstname, ' ', U.lastname) AS 'User Full Name',
U.email AS USEREMAIL,
CASE
WHEN U.statuskey IS NULL THEN 'Not Available'
WHEN U.statuskey = 0 THEN 'Inactive'
WHEN U.statuskey = 1 THEN 'Active'
ELSE U.statuskey
END 'USER STATUS VALUE',
U.owner AS USERMANGER,
CASE
WHEN ACC.status IS NULL THEN ''
WHEN ACC.status = 1 THEN 'Active'
WHEN ACC.status = 2 THEN 'In Active'
ELSE ACC.status
END 'ACCOUNT STATUS'
FROM accounts ACC
JOIN endpoints EP
ON ACC.endpointkey = EP.endpointkey
AND EP.displayname IN ( 'APPNAME' )
LEFT JOIN account_entitlements1 AE1
ON ACC.accountkey = AE1.accountkey
JOIN entitlement_values EV
ON AE1.entitlement_valuekey = EV.entitlement_valuekey
JOIN entitlement_types ET
ON EV.entitlementtypekey = ET.entitlementtypekey
LEFT JOIN user_accounts UA
ON UA.accountkey = ACC.accountkey
LEFT JOIN users U
ON U.userkey = UA.userkey
Comments
Post a Comment