I need to replace results on up to 9 columns based on one other column value.
If the column “role” is the value “SeniorManagement”, I want to replace what would be default hierarchical values with hard values.
Here’s how I can accomplish this now:
, CASE
WHEN d.Role = 'SeniorManagement'
THEN (Replace(p.Firstname,'John','Joe')) END as First
, CASE
WHEN d.Role = 'SeniorManagement'
THEN (Replace(p.Lastname,'TopDog','AssignedPerson')) END as Last
, CASE...
My question is, is there a less verbose way to combine these?
Pseudo ( I know this doens’t work 🙂
, CASE
WHEN d.Role = 'SeniorManagement'
THEN (Replace(p.Firstname,'John','Joe')) as First
THEN (Replace(p.Lastname,'TopDog','AssignedPerson')) as Last
THEN (Replace(p.Email,'TopDog@wherever','AssignedPerson@wherever')) as Email
Thanks
what about using a function?
and use it like