知识点:分情况讨论 case when then 解释:情况1:Case when ... then... 情况2:When ... then ... 其他情况:Else ... 结束该字段的查询:End 新定义的查询
select e.emp_no,e.first_name,e.last_name,emp.btype,s.salary,
case when emp.btype=1 then 0.1*s.salary
when emp.btype=2 then 0.2*s.salary
else 0.3*s.salary
end bonus
from employees as e ,emp_bonus as emp ,salaries as s
where e.emp_no=emp.emp_no
and emp.emp_no=s.emp_no
and s.to_date="9999-01-01"
order by emp_no asc