作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Insert into Employee values (1,'Abdul Rehman','Street No 12','Kamra Kalan')
Insert into Employee values (2,'Iram Bhatti','Street No 10','Attock')
Insert into Employee values (3,'Danial Aziz','Street No 12','Kamra Kalan')
Insert into Employee values (4,'Kashif Butt','Street No 10','Attock')
Insert into Employee values (5,'Zohaib Butt','Street No 13','Peshawar')
insert into Company values (1,'First Bank Co-Operation','Hydrabaad');
insert into Company values (2,'Small Bank Co-Operation','Kashmir');
Insert into Works values (1,2,5000)
Insert into Works values (2,1,40000)
Insert into Works values (1,3,56000)
Insert into Works values (1,4,8000)
Insert into Works values (2,2,78000)
问题:编写一个查询,以获取比 Small Bank Co operation 的每个员工收入都多的员工的姓名。
我的查询解决方案:
Select Employee.person_name from Works
inner join Employee on Employee.person_Id
=Works.Person_Id inner join Company on
Company.Company_Id=Works.Company_Id
and Salary>(Select Salary from works
Where Company.Company_name='Small Bank Co-Operation')
但是这个查询对我不起作用我怎么才能得到这个呢?
最佳答案
我认为最简单的解决方案就是连接所有表,然后从 works 表中找到工资等于最高工资的员工。
SELECT e.person_name
FROM employee e inner join works w
on e.person_Id = w.Person_Id
inner join company c
on w.Company_Id = c.Company_Id
WHERE c.Company_name = 'Small Bank Co-Operation'
and w.Salary = (SELECT max(works.Salary)
FROM works)
关于sql - 查询获取员工的薪水,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61636936/
假设我有一个 employee 表,其中有一列 salary。我想在年底时给薪水 > 4000 美元的人加薪 10%,给薪水 4000 THEN 1.1 ELSE 1.05 END 或特定函数如:I
我是一名优秀的程序员,十分优秀!