How to determine salaries greater than the average salary

Viewed 126283

Assume I have the following table

id  name city   salary  dept 

and I want to select all salaries which are greater than the average salary

10 Answers

Following shall work for you.

SELECT salary FROM table_name WHERE salary > (SELECT AVG(salary) FROM table_name);
select e.employee_id, e.department_id, e.salary from employees e
where salary > (
select  avg(salary)
from employees d where e.department_id =d.department_id)

SELECT * FROM table_name WHERE salary > (SELECT AVG(SALARY) from table_name);

Related