Find Employees NOT in the HR Department

SQL coding challenge · Difficulty: easy · +50 XP

Problem

HR is restructuring the HR department and needs a list of all employees who are NOT in HR, so they know who is unaffected.

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 |
| --- | --- | --- |
| 2 | Parvati | Finance |
| 3 | Ashna | IT |
| 5 | Shruti | Sales |
  • Return: employee_id, name, department_name
  • Exclude all employees in HR
  • Sort by name ascending

Solve this challenge on PySpark.in