3
Answers

Find sql salary

manuel joseph

manuel joseph

12y
1.8k
1

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




Answers (3)
0
Rahul Bhatt
NA 600 16.7k 12y
To achive this task make your query as folloiwng way

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

     


0
Sudhakar Chaudhary
NA 6.9k 369.7k 12y
create database cor
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

0
Suthish Nair
NA 31.7k 4.6m 12y
Using Inner Join, join both tables based on column dept_id, list the columns.
Next Recommended Forum