- 坑:不要多关联表,此题目中,可以不用员工部门表,salaries中有有效日期
select
e.emp_no,
e.first_name,
e.last_name,
b.btype,
s.salary,
case when b.btype = 1 then s.salary * 0.1
when b.btype = 2 then s.salary * 0.2
else s.salary * 0.3
end as bonus
from employees as e
join salaries as s on s.emp_no = e.emp_no
join emp_bonus as b on e.emp_no = b.emp_no
where s.to_date = '9999-01-01';