Home /
Expert Answers /
Computer Science /
each-record-in-the-table-department-represents-a-department-which-might-hire-some-employees-pa396
(Solved):
Each record in the table department represents a department which might hire some employees. ...
Each record in the table department represents a department which might hire some employees. Each record in the table employee represents an employee who works for one of the departments from the table department. The salary of each employee is known. (However, the locations of the departments are not relevant here.) Write an SQL query that returns a table comprising all the departments (dept_id) in the table department that hire at least one employee, the number of people they employ and the sum of salaries in each department. The table should be ordered by dept_id (in increasing order). For example, for: department:
You are given two tables, department and employee, with th following structure: create table department ( dept_id integer not null, dept_name varchar(30) not null, dept_location varchar(30) not nu11, unique(dept_id) ); create table employee ( emp_id integer not null, emp_name varchar(50) not null, dept_id integer not null, salary integer not null, unique(emp_id) Each record in the table department represents a department which might hire some employees. Each record in the table employee represents an employee who works for one of the denartments from the table denartment. The salarv of each
employee: \begin{tabular}{l|l|l|l} emp_id & emp_name & dept_id & salary \\ \hdashline 1 & Jojo & 20 & 5000 \\ 2 & Jopat Lal & 30 & 15000 \\ 3 & Panta Singh & 40 & 25000 \\ 4 & Banta Singh & 20 & 7500 \\ 5 & Sohan Lal & 20 & 15000 \\ 6 & Kk & 10 & 12000 \\ 7 & Bob & 20 & 35000 \\ 8 & John & 30 & 25000 \\ 9 & Smith & 40 & 5000 \end{tabular} your query should return:
your query should return: