题解 | case when

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

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

用内查询inner join 


select 
e.emp_no,
e.first_name,
e.last_name,
eb.btype,
s.salary ,
round (case when eb.btype=1 then s.salary*0.1
when eb.btype=2 then s.salary*0.2
when eb.btype=3 then s.salary*0.3 end ,1) as bonus
from salaries as s 
 join emp_bonus as eb on s.emp_no=eb.emp_no
 join employees as e on s.emp_no=e.emp_no where to_date='9999-01-01' order by emp_no asc;

全部评论

相关推荐

对空六翼:你真幸运,碰见这么好的人,不像我,秋招的时候被室友骗进cx了
实习好累,可以辞职全力准...
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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