A neighborhood bakery scheduled five deliveries, and the receipt export shows five rows. The counts agree even if one stop was scanned twice and another was never scanned. Compare the expected stop IDs with the recorded IDs before closing the route.

SELECT s.stop_id
FROM scheduled AS s
WHERE NOT EXISTS (
    SELECT 1 FROM receipts AS r WHERE r.stop_id = s.stop_id
)
ORDER BY s.stop_id;

This query gives one result per unmatched scheduled row. Give each row in the scheduled table a unique, nonempty identifier if that table represents one shift's route. If IDs restart each day, include a route date on both sides of the comparison or use a key that identifies a visit across days.

Test equal counts that hide a discrepancy

Put stops 101 through 105 in scheduled. Put 101,102,102,104,105 in the receipt fixture. The query should return 103. To find the extra scan, group receipts by stop_id and check for COUNT(*) > 1. For schedules that permit repeat visits, agree on a visit identifier first so a correct second receipt can be distinguished from a duplicate.

Match by day when numbers restart

If stop 103 can occur on Monday and Tuesday, a Tuesday receipt should leave Monday’s missing stop visible. Select both columns in the outer query and extend the subquery condition as shown below. Keep the date values in the same format on both tables, and check blank identifiers before routing the results. To test the revised match, schedule 103 on both days and record only the Tuesday scan. The result should show Monday’s 103. After adding Monday’s scan, run the query again and confirm the result is empty.

SELECT s.route_date, s.stop_id
FROM scheduled AS s
WHERE NOT EXISTS (
    SELECT 1
    FROM receipts AS r
    WHERE r.route_date = s.route_date AND r.stop_id = s.stop_id
)
ORDER BY s.route_date, s.stop_id;

Sources