我需要根据另一列值替换最多 9 列的结果。如果列“角色”是值“高级管理”,我想用硬值替换默认的层次值。我现在可以这样做:
, 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...
我的问题是,有没有更简洁的方法来组合这些?
伪(我知道这不起作用:-)
, 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
谢谢