Sum Employees salary according to depatments.
In sql server two tables is given, employee table and department table, and employee table contains approx 50 employees and his/her salary on each departments vise, and departments table contains department_id and department name, i want to to exit out sum of salary of every department separately according to each departments .

Rahul BhattPosted Jul 21, 2012, 4:49 AM
Need to use JOIN with Group BY
select TableB.dept_name, SUM(TableA.emp_salary) from Employee as TableA
Inner join Department as TableB
on TableA.emp_dept_id = TableB.dept_id
Group by TableB.dept_name