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