I got 3 tables please see the below. Currently, a car has a unique tag assigned to them. I have employees with multiple roles. There are only 3 roles. 1 = Surveyor, 2 = Admin or 3 = Engineer.
A car can be assigned to more than one employee. One car can have a surveyor, admin and engineer using it. But I would like to have a list of all car tags that do not have a surveyor.
| CarTags |
|---|
| tag |
| company_name |
| account_id |
| Employees |
|---|
| id |
| name |
| account_id |
| role_id |
| Roles |
|---|
| employee_id |
| role_name |
| role_id |
For the column role_id in the Roles table, there can be 3 options. 1 = Surveyor, 2 = Admin or 3 = Engineer
The below Oracle SQL query returns me a list of all car tags, company names, employee id, employee names, employee emails and role id's but how can I get a list of all car tags which do not have a surveyor assigned to it?
SELECT
cartags.tag AS "TAG Name",
cartags.company_name AS "Company Name",
Employees.id AS "Employee ID",
Employees.name AS "Employee Name",
Employees.email AS "Email Address",
Roles.id AS "Role ID"
FROM
Employees INNER JOIN cartags ON cartags.account_id = Employees.acount_id
INNER JOIN Roles ON roles.employee_id = Employees.id