Using Subquery to find salary above average
Wed Feb 16 2022 08:12:27 GMT+0000 (Coordinated Universal Time)
Saved by
@Bambibo9799
-- 1 method
select e.name, t.deptname, e.salary from
(select avg(salary) as averagesalary from tblemployee) as Budget, --first from
tblemployee as e --second from
join tbldepartment t
on e.deptid = t.deptid
where e.salary > Budget.averagesalary;
-- 2th method
select e.name, t.deptname, e.salary from
tblemployee as e
join tbldepartment t
on e.deptid = t.deptid
where e.salary > (select avg(salary) as averagesalary from tblemployee);
content_copyCOPY
Comments