case关联表查询

select
a.员工编号,b.`姓名`,b.`地址`,
case
when a.收入 is null then '没钱'
when a.收入 < 2000 then '低收入'
when a.收入 >=2000 and 收入 <=3000 then '中等收入'
else '高收入'
end as '收入水平'
from salary a,employees b where a.员工编号=b.员工编号

猜你喜欢

转载自www.cnblogs.com/liyunchuan/p/8999006.html