Kishore Kumar Kishore Kumar - 1 year ago 67
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
is total sum of all the employees.

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download