There are two tables with the columns shown in brackets.
a. Employee(emp_id,emp_name,emp_salary,emp_dept_id)
b.Department(dept_id,dept_name)
Write a SQL to show the total salary for each department
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Suthish NairRank #92 · 22.8K reputationPosted Jul 20, 2012, 10:03 AM EDT
Sudhakar ChaudharyRank #1,379 · 1.2K reputationPosted Jul 20, 2012, 10:29 AM EDT
use cor
create table employee(emp_id int,emp_name varchar(50),emp_salary decimal(18,2),emp_dept_id int)
select * from employee
create table department(dept_id int,dept_name varchar(50))
SELECT employee.emp_dept_id, department.dept_name,sum(employee.emp_salary)as Salary
FROM department INNER JOIN employee ON department.dept_id = employee.emp_dept_id GROUP BY
employee.emp_dept_id,department.dept_name
Rahul Bhatt165 reputationPosted Jul 20, 2012, 9:42 PM EDT
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