题解 | #获取有奖金的员工相关信息。#

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

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

考察表连接和 CASE WHEN
连接后的大表中,用 case when 去判断 bonus

select c.emp_no
      ,c.first_name
      ,c.last_name
      ,d.btype
      ,c.salary
      ,(case when d.btype=1 then c.salary*0.1
             when d.btype=2 then c.salary*0.2
        else c.salary*0.3 
        end) as bonus
from
     (select a.emp_no
            ,a.first_name
            ,a.last_name
            ,b.salary
      from employees a
      left join salaries b
      on a.emp_no=b.emp_no
      where b.to_date='9999-01-01') c
left  join emp_bonus d
on c.emp_no= d.emp_no
where d.btype is not null
全部评论

相关推荐

09-14 17:23
门头沟学院
故事和酒66:所以说副业很重要,程序员干到40岁,再怎么也赚300万了,吃吃利息也够活下去
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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