DataLane

4. Orders with more than one line

easyNot started~8 minAggregation

Asked in screens shaped like: Instacart, DoorDash, Shopify

Multi-line orders are the ones that break naive revenue joins, so find them first. Return every order carrying more than one line item, with its line count and total quantity.

Requirements

  • Columns: order_id, line_count, total_qty
  • Only orders with two or more rows in order_items
  • line_count is the number of lines, total_qty is SUM(qty)
  • Order by order_id

Expected output

order_id, line_count, total_qty

Row order is graded, so ORDER BY matters here.

SQL editor

Loading SQL engine…

Ctrl/Cmd + Enter submits

Run your query to see the result set.

↑↓ navigate openesc close