OiO.lk Blog SQL SQL query to select average salary for each employee
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:

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



You need to sign in to view this answers

Exit mobile version