test.sql
我是想获取3条以上的重复数据,然后获取最新一条 然后获取重复的条数,重复数据 中间是不能断的,如果是 1 2 2就不行
这样 我就获取 2021-3-7的数据 麻烦帮忙写一下
最后我想要的结果是 2,2021-3-07 ,4
select content,max(time) as max_time,count(1) as u
from
(select *
,row_number() over(partition by content order by time asc) m1
,row_number() over(order by time asc) m2
from test
) m group by content,m2-m1 HAVING count(1)>=3
__________
SELECT content,MAX(TIME) TIME,COUNT(content) contents
FROM test
GROUP BY content
HAVING COUNT(content) >= 3