发布网友 发布时间:2022-04-24 16:38
共4个回答
热心网友 时间:2022-04-08 03:03
1、创建测试表,create table test_group(pid number, sid varchar2(20));
2、插入测试数据,
insert into test_group values(1,'001');
insert into test_group values(2,'001');
insert into test_group values(2,'002');
insert into test_group values(2,'002');
insert into test_group values(2,'002');
insert into test_group values(3,'003');
insert into test_group values(3,'003');
insert into test_group values(null,'004');
3、查询表中记录,select t.*, rowid from test_group t;
4、编写sql,将记录分组后,记录组数,结果为4组,
select count(*) from (select count(*) num,sid from test_group group by sid)
热心网友 时间:2022-04-08 04:21
select count(*) num,sid into #a from person group by sid热心网友 时间:2022-04-08 05:56
from括号后面要带重命名热心网友 时间:2022-04-08 07:47
select count(*) from (select sid from person group by sid) s;