Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Cumulative orders per product

SQL data engineering interview problem. Difficulty: intermediate. Pattern: Window Functions. About 12 minutes. Part of the Pro drill bank.

For each lb_orders row, return: product, order_date, cumulative_order_count: running count of orders for that product ordered by order_date, order_id. Order by product, order_date, order_id.

Constraints

  • Break same-day ties with order_id.

Examples

Input: lb_orders (Widget) product | order_id | order_date Widget | 6 | 2024-01-15 Widget | 7 | 2024-01-20 Output: product | order_date | cumulative_order_count Widget | 2024-01-15 | 1 Widget | 2024-01-20 | 2 Why this passes: Running count grows with each Widget row in date order.

Topics: lakebench, sql, cumulative, count.

More SQL interview questions · All interview problems · Learn data engineering

intermediate

Cumulative orders per product

Interview-style drill: Cumulative count of orders for each product over time.

For each `lb_orders` row, return: `product`, `order_date`, `cumulative_order_count`: running count of orders for that product ordered by order_date, order_id. Order by `product`, `order_date`, `order_id`.