题解 | #获取有奖金的员工相关信息。#
获取有奖金的员工相关信息。
http://www.nowcoder.com/practice/5cdbf1dcbe8d4c689020b6b2743820bf
先筛选出salaries表中 to_date 为"9999-01-01" 然后再连接另外两个表 bonus计算: round(if(btype="1", salary * 0.1, if(btype="2", salary * 0.2, salary * 0.3)), 1) bonus round(..., 1) --- 保留一位小数
select emp_no, first_name, last_name, btype, salary,
round(if(btype="1", salary * 0.1, if(btype="2", salary * 0.2, salary * 0.3)), 1) bonus
from employees join emp_bonus using(emp_no)
join
(select * from salaries
where to_date = "9999-01-01") t using(emp_no);