I have a planning table like this:
| ID | EmployeeID | ExternalID | JobID |
|---|---|---|---|
| abc | 1 | null | a |
| def | 1 | null | b |
| ghi | null | 2 | a |
| jkl | null | 2 | f |
| mno | 5 | null | d |
I want to filter the rows by using an AND condition between EmployeeID and ExternalID grouping by the JobID. If I want the plannings for Employee 1 and External 2 the result should be:
| ID | EmployeeID | ExternalID | JobID |
|---|---|---|---|
| abc | 1 | null | a |
| ghi | null | 2 | a |
I'm trying using subqueries but the group by is making it hard to then filter the result with a simple WHERE EmployeeID = 1 AND ExternalID = 2.
Since the result should be displayed on a frontend table, where the filtering happens, I want it to return all the JobIDs that have the selected Employees and Externals. The JobID is not given beforehand.