Could you please help me on this MySQL question. One of your experts help me on
ID: 3737118 • Letter: C
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. 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
Explanation / Answer
Hi,
Select DECODE(e.DEPARTMENT_ID,NULL,'NONE',e.DEPARTMENT_ID) 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 DECODE(e.DEPARTMENT_ID,NULL,'NONE',e.DEPARTMENT_ID);
Please use the above query and it is working fine. Instead of ISNULL, i used DECODE.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.