Find the Dominant Seller
Problem statement
The table sellers stores one row per seller, and orders stores completed orders.
For each seller, compute total_revenue = SUM(item_qty * item_rate) across that seller's orders. A seller with no orders has total revenue 0.
A seller is dominant when their total revenue is strictly greater than the combined total revenue of all other sellers. Return every dominant seller's seller_id and total_revenue, ordered by seller_id ascending.
| Column | Meaning |
|---|---|
seller_id | Unique seller identifier |
seller_name | Seller name |
| Column | Meaning |
|---|---|
order_id | Unique order identifier |
seller_id | Seller that received the order |
item_qty | Number of items sold |
item_rate | Exact rate per item |
Table schema
Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.
sellers
One row per seller.
| Column | Type | Nullable | Description |
|---|---|---|---|
| seller_idPK | Integer | No | — |
| seller_name | Text | No | — |
orders
Completed orders attributed to sellers.
| Column | Type | Nullable | Description |
|---|---|---|---|
| order_idPK | Integer | No | — |
| seller_id | Integer | No | — |
| item_qty | Integer | No | — |
| item_rate | Decimal | No | — |
Foreign key: seller_id → sellers(seller_id)
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| seller_id | Integer | No | — |
| total_revenue | Decimal | No | — |
Row order: must match exactly. Numeric tolerance: 0.
Constraints
- The
sellerstable has between1and10^5rows. - The
orderstable has between0and2 * 10^5rows. seller_idandorder_idare unique and non-null.- Every
orders.seller_idreferences an existing seller. seller_name,item_qty, anditem_rateare non-null.0 <= item_qty <= 10^6.0 <= item_rate <= 10^9, with at most12digits after the decimal point.