Question
Could you please help me on this MySQL problem. MySQL file is attached. Three Ghegg experts tried to help but still it doesn't work for
Could you please help me on this MySQL problem. MySQL file is attached. Three Ghegg experts tried to help but still it doesn't work for the following questions. Ypu may checked them 3/19, and two times today. You may check. None works it gives error 1604, 1633, and 1366. Please help me
10. 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.
11. The COO (Chief Operating Officer) saw the report you generated in step 10 above. He wants you to run a new report that simply leaves out the line that references the employee with no department. Reissue the query, you framed in step 10 above, to meet the COO's new request. HINT: If you are HAVING any difficulty with this request, review the MySQL 5.7 Reference Manual, 13.2.9 SELECT Syntax at http://dev.mysql.com/doc/refman/5.7/en/select.html. Scroll down to find the HAVING command.
12. The COO likes the new report much better. He asks you to produce a similar report that shows how much money is spent on salaries annually for each of the departments. HINT: Your query will be a bit of a hybrid of the one from steps 10 and 11.
13. Can you think of an alternative approach to step 12 without HAVING to limit results by using an aggregate function? WHERE might you come up with such an idea? If you can figure this one out, include it as the last entry in your log file.
MySQL file
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started