Question: Write a query to display all employees with the total number of dependents. Display three columnsDepartment Name, Employee Name, and # of dependents. List the
Write a query to display all employees with the total number of dependents. Display three columnsDepartment Name, Employee Name, and # of dependents. List the employee name as first and last name with a space in between.

CREATE TABLE employee ( emp_ssn CHAR(9) PRIMARY KEY, emp_last_name VARCHAR(25) NOT NULL, emp_first_name VARCHAR(25) NOT NULL, emp_middle_name VARCHAR(25), emp_address VARCHAR(50), emp_city VARCHAR(15), emp_state CHAR(2), emp_zip CHAR(9), emp_date_of_birth DATE, emp_salary INT NOT NULL, CONSTRAINT ck_emp_salary CHECK (emp_salary
/*Drop tables if they exist*/ SET FOREIGN_KEY_CHECKS = 0; DROP TABLE if exists equipment; DROP TABLE if exists dependent; DROP TABLE if exists assignment; DROP TABLE if exists employee; DROP TABLE if exists project; DROP TABLE if exists dept_location; DROP TABLE if exists department; /* Create department table */ CREATE TABLE department ( dpt_no INT PRIMARY KEY, dpt_name VARCHAR(20) NOT NULL, dpt_mgrssn CHAR(9), dpt_mgr_start_date DATE); /* Create dept_locations table */ CREATE TABLE dept_location ( dpt_no INT NOT NULL, dpt_location VARCHAR(20), PRIMARY KEY (dpt_no, dpt_location), FOREIGN KEY (dpt_no) REFERENCES department(dpt_no)); /* Create project table */ CREATE TABLE project ( pro_num INT, pro_name VARCHAR(25) NOT NULL, pro_location VARCHAR(25), pro_dept_num INT, PRIMARY KEY (pro_num), FOREIGN KEY (pro_dept_num) REFERENCES department(dpt_no)); /* Create employee table */ CREATE TABLE employee ( emp_ssn CHAR(9) PRIMARY KEY, emp_last_name VARCHAR(25) NOT NULL, emp_first_name VARCHAR(25) NOT NULL, emp_middle_name VARCHAR(25), emp_address VARCHAR(50), emp_city VARCHAR(15), emp_state CHAR(2), emp_zip CHAR(9), emp_date_of_birth DATE, emp_salary INT NOT NULL, CONSTRAINT ck_emp_salary CHECK (emp_salary\begin{tabular}{|lll} \hline Department & Employee & \# of Dependents \\ \hline Admin and Records & Hyder Amin & 0 \\ Admin and Records & Marcia Markis & 0 \\ Admin and Records & Suzanne Joyner & 1 \\ Headquarters & Bjjoy Bordoloi & 4 \\ Production & Dinesh Joshi & 0 \\ Production & Sherri Prescott & 0 \\ Production & Waiman Zhu & 3 \\ Production & Douglas Bock & 5 \end{tabular}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
