# Write a SOQL query to find active Service Resources that have no appointments scheduled tomorrow.

**Topic:** Field Service · **Difficulty:** Medium · **Tags:** SOQL, Anti-Join, Service Resource

Read it on the site: https://www.forcechallenges.com/interview-questions/write-a-soql-query-to-find-active-service-resources-that-have-no-appointments-scheduled-tomorrow

## Answer

Use an **anti-join**: select active resources whose Id is **not in** the set of resources assigned to appointments tomorrow.

```soql
SELECT Id, Name
FROM ServiceResource
WHERE IsActive = true
AND Id NOT IN (
    SELECT ServiceResourceId
    FROM AssignedResource
    WHERE ServiceAppointment.SchedStartTime = TOMORROW
)
```

**Why it works**
- The subquery returns the Ids of resources that already have work tomorrow.
- `NOT IN` keeps everyone else, which gives the available technicians.
- Filtering on a parent field (`ServiceAppointment.SchedStartTime`) inside the subquery is allowed.

A dispatcher can use this list to find who can take extra jobs, or feed it into Fill-In Schedule.

---
Source: ForceChallenges · last updated 2026-10-28
