I have a department table and i find out to total salary of each employee by department Id.
DeptId       Name      Salary
1            AA        2000 
1            AA       3000 
2            BB       1000sql query3 cc 10003 cc 4000
SELECT E.DeptId,ISNULL(SUM(ES.Salary),0) AS Amt FROM Employee E
LEFT OUTER JOIN Employee ES ON E.DeptId=ES.DeptId
GROUP BY E.DeptId
Output
DeptId             Salary
1                   5000 
2                   10003 5000
 
No comments :
Post a Comment