Total completed revenue

aggregations

Total completed revenue

Walmart SQL Interview Question

Walmart's CFO is preparing the quarterly board report and wants one headline number for online sales. Only completed orders count as revenue, because canceled orders were never paid and refunded orders gave the money back.

Find the total amount of all completed orders as total_revenue.

Asked of

  • Data Analyst
  • Business Analyst
  • BI Analyst
  • ML Engineer
  • AI Engineer

ordersTable35 rows

Column NameType
order_idBIGINT
customer_idBIGINT
order_dateDATE
statusVARCHAR
amountDOUBLE

ordersExample Input

order_idcustomer_idorder_datestatusamount
100112024-01-05completed120.5
100222024-01-07completed2400
100312024-01-11completed89.99
100432024-01-15canceled45
100542024-01-18completed610.75
100622024-01-22completed1850.25
100752024-01-29completed3200
100812024-02-02refunded75
100962024-02-06completed55.4
101032024-02-09completed132.6

Example Output

total_revenue
8459.49

Explanation

Eight of the ten orders in the example were completed, and together they are worth 8,459.49. The canceled order worth 45 and the refunded order worth 75 are not included.

The example above is a small slice of the data. Your query runs against the full tables.