对
对对对
我有一个这样的表
试试这样:
SELECT t.date,
t.test,
sum(t.r) OVER (ORDER BY t.date)
FROM (
SELECT DATE,
test,
CASE WHEN lag(test) OVER (order by date) IS null Then 1
WHEN test <> lag(test) OVER (order by date) Then 1
ELSE 0
END as r
FROM tableA
)t
db小提琴