List All Employees With Department Names

SQL coding challenge · Difficulty: easy · +50 XP

Problem

Onboarding needs a full employee directory with each person's department name (not just the department ID).

Tables

Table: Employee

| employee_id | name | department_id |
| --- | --- | --- |
| 1 | Krishna | 1 |
| 2 | Parvati | 2 |
| 3 | Ashna | 3 |
| 4 | Pinki | 1 |
| 5 | Shruti | 4 |

Table: Department

| department_id | department_name |
| --- | --- |
| 1 | HR |
| 2 | Finance |
| 3 | IT |
| 4 | Sales |

Expected Output

| employee_id | name | department_name |
| --- | --- | --- |
| 1 | Krishna | HR |
| 2 | Parvati | Finance |
| 3 | Ashna | IT |
| 4 | Pinki | HR |
| 5 | Shruti | Sales |
  • Return: employee_id, name, department_name
  • Sort by name ascending

Solve this challenge on PySpark.in