Leveraging Intelligent Recommendations for Operational Transformation. AMS Partners click HERE | EMEA/APJ Partners click HERE |
07/03/2024 08:49 PM
Hello
I want to generate the StemUserName according to the following conditions.
all lowercases and limited to 20 characters if necessary truncate last name
only take firstname first letter
<Lower Case FirstName>.<Lower Case LastName><xxx> - where xxx is only used to avoid duplication. So if we have two users named Smith Jorden, the first would be
s.jorden and the second would be s.jorden001.
07/03/2024 08:54 PM
LEFT(CASE WHEN users.firstname IS NOT NULL AND users.firstname!= '' THEN LOWER(SUBSTRING(users.firstname, 1, 1)) || '.' || LOWER(SUBSTRING(users.lastname, 1, 16)) ELSE LOWER(SUBSTRING(users.firstname, 1, 1)) || '.' || LOWER(SUBSTRING(users.lastname, 1, 16)) END || LPAD(ROW_NUMBER() OVER (PARTITION BY CASE WHEN users.firstnameIS NOT NULL AND users.firstname!= '' THEN LOWER(SUBSTRING(users.firstname, 1, 1)) || '.' || LOWER(SUBSTRING(users.lastname, 1, 16)) ELSE LOWER(SUBSTRING(users.firstname, 1, 1)) || '.' || LOWER(SUBSTRING(users.lastname, 1, 16)) END ORDER BY users.id)::text, 3, '0'), 20)