题目如下:写一句sql求连续出现3次的数字

—1.建表
create table t1(
aid number,
nu number
);
—2.插入数据
insert into t1 values(1,2);
insert into t1 values(2,0);
insert into t1 values(3,1);
insert into t1 values(4,1);
insert into t1 values(5,1);
insert into t1 values(6,3);
insert into t1 values(7,0);
insert into t1 values(8,1);
commit;
—3.查询语句
with t2 as
(select t1.*, t1.aid - row_number() over(order by nu, aid) rk from t1)
select nu from t2 group by nu, rk having count (*) >= 3;
1946

被折叠的 条评论
为什么被折叠?



