DataLane

1. Completed revenue by country

mediumProNot started~10 minAggregation

Asked in screens shaped like: Stripe, Shopify, Square

← Prev1 / 27Next →

Finance wants revenue by country, but only for orders that actually completed. Cancelled orders must not contribute a cent. Return one row per country with revenue rounded to 2 decimals, biggest country first.

Requirements

  • Columns: country, revenue
  • Only status = 'completed' rows count
  • revenue is ROUND(SUM(amount), 2)
  • Order by revenue descending

Expected output

country, revenue

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.

Pro problem

Medium problems unlock with Pro

Easy pads stay free. Medium and hard SQL and Python problems — editor, tests, hints, and solutions — open after you upgrade to Pro or coaching.

See plansPractice free easy problems
↑↓ navigate openesc close