
Total completed revenue
easyTotal 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 Name | Type |
|---|---|
| order_id | BIGINT |
| customer_id | BIGINT |
| order_date | DATE |
| status | VARCHAR |
| amount | DOUBLE |
ordersExample Input
| order_id | customer_id | order_date | status | amount |
|---|---|---|---|---|
| 1001 | 1 | 2024-01-05 | completed | 120.5 |
| 1002 | 2 | 2024-01-07 | completed | 2400 |
| 1003 | 1 | 2024-01-11 | completed | 89.99 |
| 1004 | 3 | 2024-01-15 | canceled | 45 |
| 1005 | 4 | 2024-01-18 | completed | 610.75 |
| 1006 | 2 | 2024-01-22 | completed | 1850.25 |
| 1007 | 5 | 2024-01-29 | completed | 3200 |
| 1008 | 1 | 2024-02-02 | refunded | 75 |
| 1009 | 6 | 2024-02-06 | completed | 55.4 |
| 1010 | 3 | 2024-02-09 | completed | 132.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.
Company
Walmart
Difficulty
easy
Topic
aggregations
Your query
Starting the SQL engine...