提薪后获得低于平均工资的员工 [英] Get Employees Who Are Below Average Salary After A Raise

查看:43
本文介绍了提薪后获得低于平均工资的员工的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使获得了10%的加薪,我也需要获得低于平均工资400.00美元的雇员的全名,全名,工资.

I need to get fname, lname, salary of employees who are $400.00 below the average salary even after geting a 10% salary raise.

我能够让薪水低于平均薪水的员工,但是不确定如何在加薪后让薪水低于400美元的员工.

I'm able to get employees who's salary is below the average salary, but am unsure how to get those who are $400 below after a raise.

我正在使用MySQL.谢谢.

I'm using MySQL. Thank you.

select AVG(salary) from employee; #gives me the average salary

select Fname, Lname, Salary, 1.10*Salary as NewSalary
from employee; 
#gives me names, old salary and salary raised.

这给了我工资低于平均工资的员工:

This gives me the employees with salary less than the average salary:

select Fname, Lname, Salary
from employee
where Salary < (select AVG(salary) from employee);

我当时在想类似的事情,但这是行不通的.未知专栏新闻:

I was thinking something like this, but this doesn't work; unknown column newsalary:

select Fname, Lname, Salary, 1.10*Salary as NewSalary
from employee
where NewSalary - (select AVG(salary) from employee) = 400 ;

推荐答案

您有一个正确的想法,就是不能在 where 子句中使用别名.只需直接使用公式,就可以了.另外,您可能应该使用< = ,而不是 = :

You have the right idea, you just can't use aliases in the where clause like that. Just use the formula directly, and you should be fine. Also, you should probably use <=, and not =:

select Fname, Lname, Salary, 1.10 * Salary as NewSalary
from   employee
where  1.10 * Salary - (select AVG(salary) from employee) <= 400;

这篇关于提薪后获得低于平均工资的员工的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆