select emp_no, first_name, last_name, btype, salary, case when btype=1 then round(salary*0.1,1) when btype=2 then round(salary*0.2,1) else salary*0.3 end as bonus from employees left join emp_bonus using(emp_no) right join salaries using(emp_no) where btype is not null and to_date='9999-01-01' order by emp_no