Data AnalystQuestion 7 of 57
Handling NULLs with COALESCE
Problem
You are generating an organization chart CSV file, but the software crashes when it hits a NULL manager_id for the CEO. Retrieve first_name and manager_id, but if manager_id is NULL, return the string "CEO" instead.
Database Schema
Table: employees
employee_id(INT): Unique identifier for the employee.first_name(VARCHAR): First name of the employee.last_name(VARCHAR): Last name of the employee.salary(INT): Employee's salary.department_id(INT): Foreign key referencing the department.manager_id(INT): Foreign key referencing the manager (another employee).hire_date(DATE): Date the employee was hired.
Table: departments
department_id(INT): Unique identifier for the department.department_name(VARCHAR): Name of the department.
Try It
Loading playground environment...