Question: Could you please help me on this MySQL question. One of your experts help me on this on 3/19/18. I am sure he did correct.

Could you please help me on this MySQL question. One of your experts help me on this on 3/19/18. I am sure he did correct. But when I type this in MySQL I get error 1064. Could you please help me on this

Thanks for helping me

Q10

How many employees are in each department? HINT: not all employees have been assigned to a department. We want that person to be included in the report. Use the same technique you employed in step 6 above to replace the word "NULL" with "none"for the department_id if it is null. Your report should display the department_id with the total number of employees in that department. Sort the results by department_id.

SQL Code

Select ISNULL(Convert(Varchar(100), d.department_id),'None') As Department_Id, COUNT(Employee_Id) As TotalEmployee from employee as e left join department as d on d.department_id = e.department_id Group By ISNULL(Convert(Varchar(100), d.department_id),'None'):

This is the MySQL database

CREATE DATABASE SQL101; USE SQL101; CREATE TABLE employee ( employee_id INTEGER, first_name VARCHAR(30), last_name VARCHAR(30), hire_date DATE, salary DECIMAL(9,2), manager INTEGER, department_id INTEGER ); CREATE TABLE department ( department_id INTEGER, name VARCHAR(30), location VARCHAR(30) ); INSERT INTO employee (employee_id, first_name, last_name, hire_date, salary, manager, department_id) VALUES (28, 'Emily', 'Eckhardt', STR_TO_DATE('07-JUL-2008', '%d-%M-%Y'), 100000, NULL, 10); INSERT INTO employee (employee_id, first_name, last_name, hire_date, salary, manager, department_id) VALUES (37, 'Frances', 'Newton', STR_TO_DATE('14-SEP-2009', '%d-%M-%Y'), 75000, NULL, NULL); INSERT INTO employee (employee_id, first_name, last_name, hire_date, salary, manager, department_id) VALUES (1234, 'Donald', 'Newton', STR_TO_DATE('24-SEP-2010', '%d-%M-%Y'), 80000, 28, 10); INSERT INTO employee (employee_id, first_name, last_name, hire_date, salary, manager, department_id) VALUES (7895, 'Matthew', 'Michaels', STR_TO_DATE('16-MAY-2011', '%d-%M-%Y'), 70000, 28, 10); INSERT INTO employee (employee_id, first_name, last_name, hire_date, salary, manager, department_id) VALUES (6567, 'Roger', 'Friedli', STR_TO_DATE('16-MAY-2011', '%d-%M-%Y'), 60000, 28, 10); INSERT INTO employee (employee_id, first_name, last_name, hire_date, salary, manager, department_id) VALUES (6568, 'Betsy', 'James', STR_TO_DATE('16-MAY-2011', '%d-%M-%Y'), 60000, 28, 10); INSERT INTO employee (employee_id, first_name, last_name, hire_date, salary, manager, department_id) VALUES (6569, 'michael', 'peterson', STR_TO_DATE('03-NOV-2012', '%d-%M-%Y'), 90000, NULL, 20); INSERT INTO employee (employee_id, first_name, last_name, hire_date, salary, manager, department_id) VALUES (6570, 'mark', 'leblanc', STR_TO_DATE('06-MAR-2013', '%d-%M-%Y'), 65000, 6569, 20); INSERT INTO employee (employee_id, first_name, last_name, hire_date, salary, manager, department_id) VALUES (6571, 'Thomas', 'Jeffrey', STR_TO_DATE('27-FEB-2014', '%d-%M-%Y'), 300000, null, 30); INSERT INTO employee (employee_id, first_name, last_name, hire_date, salary, manager, department_id) VALUES (6572, 'Theresa', 'Wong', STR_TO_DATE('27-FEB-2014', '%d-%M-%Y'), 70000, 6571, 30); INSERT INTO employee (employee_id, first_name, last_name, hire_date, salary, manager, department_id) VALUES (6573, 'Lori', 'Dovichi', STR_TO_DATE('07-JUL-2014', '%d-%M-%Y'), null, 28, 10); INSERT INTO employee (employee_id, first_name, last_name, hire_date, salary, manager, department_id) VALUES (6574, 'Fred', 'Fardbarkle', STR_TO_DATE('09-DEC-2014', '%d-%M-%Y'), 35575, 6571, 30); INSERT INTO department (department_id, name, location) VALUES (10, 'Accounting', 'LOS ANGELES'); INSERT INTO department (department_id, name, location) VALUES (20, 'Payroll', 'NEW YORK'); INSERT INTO department (department_id, name, location) VALUES (30, 'IT', 'WASHINGTON DC'); Commit;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!