October 27, 2024
Chicago 12, Melborne City, USA
SQL

SQL query to select average salary for each employee


When I tried to select employee fname,lname, salary and the average of the salary it returned the same number for all employee.
here what I typed to query:

SELECT 
    Fname AS EmployeeFirstName, 
    Lname AS EmployeeLastName, 
    Salary AS Sal, 
    (SELECT AVG(Salary) FROM Employee) AS AverageSalary,
FROM 
    Employee;

And this is the screenshot of the result:
enter image description here

I want the average be counted for each employee salary, any idea?



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video