Click HERE to see how Saviynt Intelligence is transforming the industry. |
08/22/2024 06:04 AM
I have the following rule and I have a use case where there are spaces in the last name and first name I need to remove those spaces. Can someone assist with my current rule with removing those spaces?
case when length(trim(users.lastname)) between 2 and 50 then
concat
(
substring(users.firstname,1,1), users.lastname
,
case
when (select count(*) from users X where substring(X.firstname,1,1) = substring(users.firstname,1,1) and X.lastname = users.lastname) in (0 , 1) then ''
else
(select count(*) from users X where substring(X.firstname,1,1) = substring(users.firstname,1,1) and X.lastname = users.lastname)
end
)
else
concat(users.firstname, users.lastname,
case
when (select count(*) from users X where X.firstname = users.firstname and X.lastname = users.lastname) in (0 , 1) then ''
else
(select count(*) from users X where X.firstname = users.firstname and X.lastname = users.lastname)
end
)
end
08/22/2024 06:15 AM
CASE
WHEN LENGTH(TRIM(users.lastname)) BETWEEN 2 AND 50 THEN
CONCAT
(
SUBSTRING(REPLACE(users.firstname, ' ', ''), 1, 1),
REPLACE(users.lastname, ' ', ''),
CASE
WHEN (SELECT COUNT(*) FROM users X
WHERE SUBSTRING(REPLACE(X.firstname, ' ', ''), 1, 1) = SUBSTRING(REPLACE(users.firstname, ' ', ''), 1, 1)
AND REPLACE(X.lastname, ' ', '') = REPLACE(users.lastname, ' ', '')) IN (0, 1) THEN ''
ELSE
(SELECT COUNT(*) FROM users X
WHERE SUBSTRING(REPLACE(X.firstname, ' ', ''), 1, 1) = SUBSTRING(REPLACE(users.firstname, ' ', ''), 1, 1)
AND REPLACE(X.lastname, ' ', '') = REPLACE(users.lastname, ' ', ''))
END
)
ELSE
CONCAT(REPLACE(users.firstname, ' ', ''), REPLACE(users.lastname, ' ', ''),
CASE
WHEN (SELECT COUNT(*) FROM users X
WHERE REPLACE(X.firstname, ' ', '') = REPLACE(users.firstname, ' ', '')
AND REPLACE(X.lastname, ' ', '') = REPLACE(users.lastname, ' ', '')) IN (0, 1) THEN ''
ELSE
(SELECT COUNT(*) FROM users X
WHERE REPLACE(X.firstname, ' ', '') = REPLACE(users.firstname, ' ', '')
AND REPLACE(X.lastname, ' ', '') = REPLACE(users.lastname, ' ', ''))
END
)
END