Reinforce Labs·Software Engineer·Technical Phone Screen
- Given a products table and a stock_movements table (with movement types INCOMING, OUTGOING, and RETURN), write a SQL query that returns each product's current stock level, calculated as total incoming plus returns minus outgoing. Products with zero stock should still appear in the results, ordered by product_id.
“My first instinct was a simple GROUP BY with SUM, but I almost forgot about the RETURN type adding back to stock, which would've tanked the numbers.”