The Sales Person interview question is a SQL problem where you must find all salespeople who have NOT made any sale to the company "RED." Given a SalesPerson table, Orders table, and Company table, return the names of salespeople with no orders associated with the "RED" company. This is a classic "find entities not associated with a condition" SQL pattern.
Meta, Amazon, and Bloomberg ask this SQL problem because the "find A where NOT EXISTS/NOT IN B" pattern is one of the most common in business analytics: find customers who haven't purchased in 30 days, users who haven't logged in, salespeople who haven't hit quota. It evaluates whether candidates know set-difference logic in SQL and how to handle it safely.
The pattern is NOT IN or NOT EXISTS with a subquery. Find all sales_ids associated with company "RED" via the Orders and Company join. Then select salespeople whose sales_id is NOT in that list:
SELECT name
FROM SalesPerson
WHERE sales_id NOT IN (
SELECT o.sales_id
FROM Orders o
JOIN Company c ON o.com_id = c.com_id
WHERE c.name = 'RED'
);
Or using NOT EXISTS:
SELECT sp.name
FROM SalesPerson sp
WHERE NOT EXISTS (
SELECT 1 FROM Orders o
JOIN Company c ON o.com_id = c.com_id
WHERE o.sales_id = sp.sales_id AND c.name = 'RED'
);
SalesPerson: Alice (id=1), Bob (id=2), Carol (id=3). Orders: (com_id=RED, sales_id=1), (com_id=BLUE, sales_id=2).
Salespeople with RED orders: {1 = Alice}. Salespeople NOT with RED: {Bob, Carol}.
Result: ["Bob", "Carol"].
com_id, not the name.<> in a join instead of NOT IN — direct filtering on a join doesn't work as expected.For the Sales Person coding problem, the database interview pattern is NOT IN / NOT EXISTS for set-difference queries. Know both approaches and when to use each: NOT EXISTS is NULL-safe and generally preferred; NOT IN is simpler but fails with NULLs in the subquery. Bloomberg and Meta interviewers often ask "what's the difference between NOT IN and NOT EXISTS?" — be ready with a clear answer. Practice this pattern on "find users who haven't done X" queries.