Goal: Display employees and their salary with very least like 2100 only.
How do I put conditions in my query where the salary should be = 2100?
Query:
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;
The output that I want should be like this:
The Database that I use is the Oracle HR Objects and Data for LiveSQL
CodePudding user response:
You just need to add a where condition -
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;
CodePudding user response:
Ummm ... why are you self-joining that table? Output you want doesn't suggest you need it. What's wrong with simple
SELECT e.first_name ||' with the salary of '|| e.salary AS Employees_and_their_Salary
FROM hr.employees e
WHERE e.salary = 2100;