Reputation: 139
I've been using SQL*PLus lately and one of my tasks was to display the EmpCode, EmpName and PostCode of all Employees who satisfy the following: Every Item they sell has a price value above the average of all stock items
EDIT: Hi Mark, I have written something similar to what you have suggested, but I am aware that the answers produced are wrong.
select E.EmpCode, E.EmpName, PostCode
from Employees E
LEFT OUTER JOIN Stocks ST
where Price >
(select AVG(Quantity) from Stocks
where E.EmpCode = ST.Empcde;
Any help would be appreciated.
Upvotes: 0
Views: 127
Reputation: 16512
Try something like this
select distinct EmpCode, EmpName, PostCode
from Employees e
LEFT JOIN Stocks st On e.columnName= st.columnName
where Price >
(select AVG(Quantity) from Stocks
where e.EmpCode = st.EmpCode)
The syntax for a LEFT JOIN is
t1 LEFT JOIN t2 ON t1.id = t2.id
Also there's a missing parenthesis at the end
Upvotes: 4