I am trying to successfully execute the following statement. It works except the else(LEFT..). I need to retrieve all the characters from the left of a field until it reaches an @. I do not want to include the @. Any suggestions? Thanks so much. Sally
CASE
PS_PERSONAL_DATA.EMAIL_ADDRESS WHEN NULL
THEN
LOWER(SUBSTRING(PS_PERSONAL_DATA.LAST_NAME,1,5) +
SUBSTRING(PS_PERSONAL_DATA.FIRST_NAME,1,1) +
SUBSTRING(PS_PERSONAL_DATA.MIDDLE_NAME,1,1))
WHEN ''
THEN
LOWER(SUBSTRING(PS_PERSONAL_DATA.LAST_NAME,1,5) +
SUBSTRING(PS_PERSONAL_DATA.FIRST_NAME,1,1) +
SUBSTRING(PS_PERSONAL_DATA.MIDDLE_NAME,1,1))
WHEN 'none'
THEN
LOWER(SUBSTRING(PS_PERSONAL_DATA.LAST_NAME,1,5) +
SUBSTRING(PS_PERSONAL_DATA.FIRST_NAME,1,1) +
SUBSTRING(PS_PERSONAL_DATA.MIDDLE_NAME,1,1))
ELSE
LEFT(PS_PERSONAL_DATA.EMAIL_ADDRESS,CHARINDEX('@',(PS_PERSONAL_DATA.EMAIL_ADDRESS) ) )
END
CASE
PS_PERSONAL_DATA.EMAIL_ADDRESS WHEN NULL
THEN
LOWER(SUBSTRING(PS_PERSONAL_DATA.LAST_NAME,1,5) +
SUBSTRING(PS_PERSONAL_DATA.FIRST_NAME,1,1) +
SUBSTRING(PS_PERSONAL_DATA.MIDDLE_NAME,1,1))
WHEN ''
THEN
LOWER(SUBSTRING(PS_PERSONAL_DATA.LAST_NAME,1,5) +
SUBSTRING(PS_PERSONAL_DATA.FIRST_NAME,1,1) +
SUBSTRING(PS_PERSONAL_DATA.MIDDLE_NAME,1,1))
WHEN 'none'
THEN
LOWER(SUBSTRING(PS_PERSONAL_DATA.LAST_NAME,1,5) +
SUBSTRING(PS_PERSONAL_DATA.FIRST_NAME,1,1) +
SUBSTRING(PS_PERSONAL_DATA.MIDDLE_NAME,1,1))
ELSE
LEFT(PS_PERSONAL_DATA.EMAIL_ADDRESS,CHARINDEX('@',(PS_PERSONAL_DATA.EMAIL_ADDRESS) ) )
END