SQL253 获取有奖金的员工 case when练习题

获取有奖金的员工相关信息。

https://www.nowcoder.com/practice/5cdbf1dcbe8d4c689020b6b2743820bf

select e1.emp_no, e1.first_name, e1.last_name, e2.btype, s1.salary, 
case when e2.btype = 1 then s1.salary*0.1
when e2.btype = 2 then s1.salary*0.2 
else s1.salary*0.3 end bonus
from employees e1 join emp_bonus e2 
on e1.emp_no = e2.emp_no
join salaries s1 on e1.emp_no = s1.emp_no
where to_date = '9999-01-01'
order by e1.emp_no

语法:

case when 条件1 then 结果1

when 条件2 then 结果2

.。。。

else 其他结果 end 描述

全部评论

相关推荐

05-26 10:24
门头沟学院 Java
qq乃乃好喝到咩噗茶:其实是对的,线上面试容易被人当野怪刷了
点赞 评论 收藏
分享
自由水:笑死了,敢这么面试不敢让别人说
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务