How to display employee records who gets more salary than the average salary in the department. Return employee ID, first name, last name.

How to display employee records who gets more salary than the average salary in the department. Jun 5, 2025 · Thursday, 5 June 2025 List out all the employees whose salary is more than average salary of their respective department First, We have to create the Table "Employees" and insert some Records as below: CREATE TABLE employees ( emp_id INT PRIMARY KEY, name VARCHAR (100), department_id INT, salary DECIMAL (10, 2) ); Oct 17, 2021 · Here we display Display employee records who gets more salary than the average salary in the department more How the Query Works The subquery (SELECT AVG(salary) FROM employees) calculates the average salary of all employees The main query then filters employees whose salary is greater than this average Results are ordered by salary in descending order (highest to lowest) Expected Output Based on our dummy data, the average salary is (75000+65000+82000+58000+90000+78000+62000+71000)/8 = 72625. The following statement assigns an alias to employees, the table containing the salary information, and then uses the alias in a correlated subquery:. If it does, then we will display all the details of the employees. Jul 23, 2025 · The subquery return average salary from each department and parent query checks in the table whether any employee has salary higher than the average. Aug 10, 2014 · i have a table called employees which i have name, department_id and salary in it. I want to find the employees whose salary is greater than the average of their department and see their names, Mar 12, 2025 · SQL SUBQUERIES Exercise, Practice and Solution: From the following table, write a SQL query to find those employees who earn more than the average salary. 00 The Jun 18, 2015 · The following statement returns data about employees whose salaries exceed their department average. Return employee ID, first name, last name. owexv nbnkh kawxmx exce zprptr cps qdcsw srikro yjltsguu tkecjr