How to get total salary department wise?


To get the total salary department wise from the Employee table you can use the Built-in function SUM with group by clause in sql server.

Department Table
DepartmentId DepartmentName
1 IT
2 Electrical
3 Mechanical
4 Civil
5 Chemical
Employee Table
EmployeeId EmployeeName Salary DepartmentId
1 Valiveti Sekhar 10000 1
2 Sai Kumar 10000 1
3 Dipti 18000 2
4 Suresh Kumar 10000 2
5 Raj Kumar 10000 2
6 Raj Kumar 11000 3
7 Manas Kumar 14000 3
8 Sanjiit 14000 4
9 Amit P 11000 2
10 Amit C 13000 1
Select D.DepartmentName,SUM(Salary) From Employee E Inner Join Department D ON E.DepartmentId=D.DepartmentId #break Group BY DepartmentName;
Result:
DepartmentName Salary
Civil 14000
Electrical 49000
IT 33000
Mechanical 25000
Share On