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

京公网安备 11010502036488号