... what's a query to show whether a given date-customer-score 3-tuple is unique for the past week?
This query finds all customer-score pairs from the last 7 days that occurred just once ...
select date, customer, score from tbl
where date >= curdate() - interval 7 day
group by customer,score
having count(*)=1;
... it checks a against one date rather than per-row dates, but the principle is the same. So is (2020-04-26,ARG,0.75) unique in the week before it was entered?
select not exists (
select date,customer, score from tbl
where customer='ARG'
and date < '2024-04-26'
and date >= '2024-04-26' - interval 7 day
and score=.75
) as new;
+-----+
| new |
+-----+
| 0 |
+-----+
No. Is (2020-04-26,HVN,0.92) new?
select not exists (
select date,customer, score from tbl
where customer='HVN'
and date < '2024-04-26'
and date >= '2024-04-26' - interval 7 day
and score=.92
) as new;
+-----+
| new |
+-----+
| 1 |
+-----+
Yes.
Such query logic can be encapsulated in a subquery such that it identifies period uniqueness as a property of rows in any rowset it can be joined to.