下面有一张表
days | ||||
---|---|---|---|---|
2022/08/01 | 2022/08/02 | 2022/08/03 | ||
2022/08/03 | ||||
2022/08/05 | 2022/08/06 | |||
2022/08/07 | ||||
2022/08/08 |
SELECT
*,
COUNT(DISTINCT CASE WHEN balance > 0 THEN USER_ID END) OVER (ORDER BY days)
FROM
your_table