直接三表联合,然后判断btype再进行bonus操作
获取有奖金的员工相关信息。
https://www.nowcoder.com/practice/5cdbf1dcbe8d4c689020b6b2743820bf
select
*,
( case
when btype = 1 then salary * 0.1
when btype = 2 then salary * 0.2
else salary * 0.3
end
) as bonus
from(
select
eb.emp_no,first_name,last_name,btype,salary
from
salaries as sa
join emp_bonus as eb on eb.emp_no = sa.emp_no
join employees as em on em.emp_no = eb.emp_no
where
to_date = '9999-01-01'
) as t1
OPPO公司福利 1202人发布