Loading problem...
A retail analytics team tracks shopper transactions and a one-row promotion policy.
Table: Purchases
Table: DiscountPolicy
Eligibility logic: A shopper is considered eligible if they have at least one purchase where:
Important boundary interpretation: Both policy dates are interpreted at midnight. This means end_date represents exactly end_date 00:00:00, not the end of that day.
Task: Return the IDs of all eligible shoppers.
Output requirements:
Supported submission environments:
Purchases:
| user_id | time_stamp | amount |
|---------|----------------------|--------|
| 1 | 2022-04-20 09:03:00 | 4416 |
| 2 | 2022-03-19 19:24:02 | 678 |
| 3 | 2022-03-18 12:03:09 | 4523 |
| 3 | 2022-03-30 09:43:42 | 626 |
DiscountPolicy:
| start_date | end_date | min_amount |
|------------|------------|------------|
| 2022-03-08 | 2022-03-20 | 1000 |[
{"user_id": 3}
]Only user 3 has a purchase that satisfies both threshold and policy-window conditions.
Purchases:
| user_id | time_stamp | amount |
|---------|----------------------|--------|
| 10 | 2024-10-10 00:00:00 | 700 |
| 10 | 2024-10-12 00:00:00 | 900 |
| 20 | 2024-10-12 00:00:01 | 900 |
| 30 | 2024-10-09 23:59:59 | 900 |
DiscountPolicy:
| start_date | end_date | min_amount |
|------------|------------|------------|
| 2024-10-10 | 2024-10-12 | 700 |[
{"user_id": 10}
]The interval includes both boundary midnights. Rows one second before/after the boundaries are excluded.
Purchases:
[]
DiscountPolicy:
| start_date | end_date | min_amount |
|------------|------------|------------|
| 2023-01-01 | 2023-12-31 | 500 |[]With no purchases, no shopper can qualify.
Constraints