Kishore Kumar Kishore Kumar - 4 months ago 10
SQL Question

How to display employee details along with sum(sal) of all employees?

Is it possible to display employee details like the below using SQL?

Emp_id, Emp_name, Emp_Sal, Sum(Emp_Sal)


Note: Here
Sum(Emp_Sal)
is total sum of all the employees.

Answer

You can get your expected result in this way:

SELECT Emp_id, Emp_name, Emp_Sal, (SELECT SUM(Emp_Sal) FROM Employee) AS TotalSalary
FROM Employee

Working DEMO