Loading problem...
An order-governance team is applying a retention policy before downstream analytics. The policy gives priority to baseline orders (type 0) over promotional orders (type 1) for each customer.
Table: Orders
Retention rule:
Task: Return the retained rows after applying the policy.
Output requirements:
Supported submission environments:
Orders:
| order_id | customer_id | order_type |
|----------|-------------|------------|
| 1 | 1 | 0 |
| 2 | 1 | 1 |
| 3 | 2 | 1 |
| 4 | 2 | 1 |
| 5 | 3 | 0 |
| 6 | 3 | 1 |[
{"order_id":1,"customer_id":1,"order_type":0},
{"order_id":3,"customer_id":2,"order_type":1},
{"order_id":4,"customer_id":2,"order_type":1},
{"order_id":5,"customer_id":3,"order_type":0}
]Customers 1 and 3 each have at least one type-0 order, so their type-1 rows are removed. Customer 2 has only type-1 orders, so both rows are retained.
Orders:
| order_id | customer_id | order_type |
|----------|-------------|------------|
| 10 | 7 | 1 |
| 11 | 7 | 1 |
| 12 | 8 | 1 |[
{"order_id":10,"customer_id":7,"order_type":1},
{"order_id":11,"customer_id":7,"order_type":1},
{"order_id":12,"customer_id":8,"order_type":1}
]No customer has a type-0 row, so all rows remain.
Orders:
[][]No input rows means no output rows.
Constraints