Merchant Revenue

ASKED IN INTERVIEW
4pts
Dropbox

Problem Statement

Dropbox provides payment infrastructure for merchants. You need to generate a report showing the revenue per merchant for each month.

Rules:

  • Output columns: merchant_id, merchant_name, transaction_month, total_revenue.
  • transaction_month format: 'YYYY-MM'.
  • Only include transactions with a status of 'Success'.
  • Results must be sorted by transaction_month in descending order, then by total_revenue in descending order.
Tests your understanding of
Date Truncation, Aggregation and Filtering

Input Tables

merchants
merchant_id(INTEGER)merchant_name(VARCHAR)
1Cloud Storage Co
2DevTools Inc
3SaaS Solutions
transactions
transaction_id(INTEGER)merchant_id(INTEGER)amount(DECIMAL)status(VARCHAR)created_at(TIMESTAMP)
101500Success2024-01-15 10:00:00
111200Success2024-01-20 12:00:00
1221000Success2024-01-05 09:00:00
131300Failed2024-01-25 15:00:00
141400Success2024-02-10 08:00:00
1531500Success2024-02-15 11:00:00
1621200Success2024-02-20 14:00:00
merchant_tiers
merchant_id(INTEGER)tier(VARCHAR)
1Gold
2Silver
3Platinum

Expected Output

merchant_id(INTEGER)merchant_name(VARCHAR)transaction_month(VARCHAR)total_revenue(DECIMAL)
3SaaS Solutions2024-021500
2DevTools Inc2024-021200
1Cloud Storage Co2024-02400
2DevTools Inc2024-011000
1Cloud Storage Co2024-01700

Tags

MediumASKED IN INTERVIEWDate TruncationAggregationFiltering
15-20 min
52%

Hints