SQL data engineering interview problem. Difficulty: intermediate. Pattern: Aggregation. About 12 minutes. Part of the Pro drill bank.
From lb_orders, return one row with: electronics_revenue: SUM of amount where product_category = 'Electronics' clothing_revenue: SUM of amount where product_category = 'Clothing' Ignore other categories.
Input: lb_orders product_category | amount Electronics | 1200 Clothing | 35 Electronics | 40 Electronics | 500 Electronics | 50 Electronics | 55 Output: electronics_revenue | clothing_revenue 1845 | 35 Why this passes: All Electronics amounts sum to 1845; Shirt is the only Clothing row.
Topics: lakebench, sql, conditional agg, case.
More SQL interview questions · All interview problems · Learn data engineering
Interview-style drill: SUM CASE WHEN for Electronics and Clothing revenue in one row.
From `lb_orders`, return one row with: - `electronics_revenue`: SUM of amount where product_category = 'Electronics' - `clothing_revenue`: SUM of amount where product_category = 'Clothing' Ignore other categories.