oracle 具有特定数量的自联接条件

x33g5p2x  于 2023-03-17  发布在  Oracle
关注(0)|答案(2)|浏览(103)

目标:仅显示最小值为2100的员工及其薪金。
如何在查询中设置条件,使薪金等于或等于2100?
质询:

SELECT e.first_name ||' with the salary of '|| d.salary 
AS Employees_and_their_Salary
FROM hr.employees e 
JOIN hr.employees d
ON e.manager_id = d.employee_id;

预期输出应为:

我使用的数据库是Oracle HR Objects and Data for LiveSQL

yrdbyhpb

yrdbyhpb1#

你只需要加个where条件-

SELECT e.first_name ||' with the salary of '|| d.salary 
AS Employees_and_their_Salary
FROM hr.employees e 
JOIN hr.employees d ON e.manager_id = d.employee_id
WHERE d.salary = 2100;
whlutmcx

whlutmcx2#

嗯......你为什么要自联接那个表?你想要的输出并不意味着你需要它。简单有什么问题吗

SELECT e.first_name ||' with the salary of '|| e.salary AS Employees_and_their_Salary
FROM hr.employees e 
WHERE e.salary = 2100;

相关问题