Table :-Person
Column:-day_phone, alt_phone ,Home_phone
条件: - 如果day_phone为null,则为alt_phone
如果两者中都没有数据则复制Home_phone
答案 0 :(得分:0)
用例和AND运算符
select Person
, case when day_phone is null then alt_phone
when day_phone is null and lt_phone is null then Home_phone
end
from my_table
答案 1 :(得分:0)
您可以使用将返回第一个非空值的COALESCE函数:
select coalesce(day_phone, alt_phone, Home_phone)
from person