1. 显示工资涨幅,员工编号,原来的工资和增加的工资: 部门号10、50、110的有5%的涨幅, 部门号为60的涨10%的工资部门号为20和80涨幅为15%,部门为90的不涨工资

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/ok3356/article/details/81104209

SELECT *
  FROM ( select 'raise 5%' raise,e.employee_id as employee_id,e.salary,e.salary*0.05 as newsalary
      from employees e
      where e.department_id in (10,50,110))
UNION ALL
SELECT *
  FROM ( select 'raise 10%' raise,e.employee_id as employee_id,e.salary,e.salary*0.10 as newsalary
      from employees e
      where e.department_id = 60)
UNION ALL
SELECT * FROM (select 'raise 15%' raise,e.employee_id as employee_id,e.salary,e.salary*0.15 as newsalary
      from employees e
      where e.department_id in (80,20))
union all
SELECT * FROM (select 'no raise' raise,e.employee_id as employee_id,e.salary,e.salary*0.00 as newsalary
      from employees e
      where e.department_id = 90)

 

展开阅读全文

没有更多推荐了,返回首页