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

Enhanced Query column update with Case statement

CR
Regular Contributor III
Regular Contributor III

Hi Team,

Can you some help on Enhanced Query build for column update with via Case statement.

Please find below SQL Script

update accounts as a
join user_accounts as ua on a.ACCOUNTKEY = ua.ACCOUNTKEY
join users as u on ua.userkey = u.userkey
set a.CUSTOMPROPERTY28 = ( CASE WHEN u.CUSTOMER ='1' THEN 'Cognizant India' WHEN u.CUSTOMER ='4' THEN 'NTT DATA' WHEN u.CUSTOMER ='6' THEN 'Telus Guatemala' END )
where a.ENDPOINTKEY in (SELECT ENDPOINTKEY FROM ENDPOINTS WHERE ENDPOINTNAME ='EBS' ) and a.name = u.systemusername and a.CUSTOMPROPERTY29 is null;


Thanks,
Raghu
If this reply answered your question, Please Accept As Solution and hit Kudos.
2 REPLIES 2

rushikeshvartak
All-Star
All-Star

SELECT
a.accountkey as accounts__primarykey,
(CASE
WHEN u.CUSTOMER = '1' THEN 'Cognizant India'
WHEN u.CUSTOMER = '4' THEN 'NTT DATA'
WHEN u.CUSTOMER = '6' THEN 'Telus Guatemala'
END) AS accounts__CUSTOMPROPERTY28
FROM
accounts AS a
JOIN
user_accounts AS ua ON a.ACCOUNTKEY = ua.ACCOUNTKEY
JOIN
users AS u ON ua.userkey = u.userkey
WHERE
a.ENDPOINTKEY IN (SELECT ENDPOINTKEY FROM ENDPOINTS WHERE ENDPOINTNAME = 'EBS')
AND a.name = u.systemusername
AND a.CUSTOMPROPERTY29 IS NULL;


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

CR
Regular Contributor III
Regular Contributor III

We got the solution, thank you


Thanks,
Raghu
If this reply answered your question, Please Accept As Solution and hit Kudos.