select t1.emp_no en, first_name, last_name, btype, salary, case when btype = 1 then salary * 0.1 when btype = 2 then salary * 0.2 else salary * 0.3 end from employees t1 left join emp_bonus t2 on (t1.emp_no = t2.emp_no) join salaries t3 on (t1.emp_no = t3.emp_no) and t3.to_date = '9999-01-01' where btype is not null order by t1.emp_no