1、创建测试表,
create table test_group_cols(id number, value varchar2(20), remark varchar2(20))
2、插入测试数据
insert into test_group_cols values(1,'15y','rmk1')
insert into test_group_cols values(2,'15y','rmk1')
insert into test_group_cols values(3,'25x','rmk2')
insert into test_group_cols values(3,'333','rmk4')
insert into test_group_cols values(3,'666','rmk3')
insert into test_group_cols values(4,'35s','rmk1')
insert into test_group_cols values(4,'77','rmk1')
3、查询该表的所有字段,select t.*, rowid from user_tab_cols t where table_name = upper('test_group_cols'),可以发现共有3个字段,
4、编写sql,按id字段进行分组,select id, count(*) from test_group_cols t group by id,
select 测站名称,avg(温度) from test where 日期 between #2015/1/6# and #2015/8/2# group by 测站名称这样吗?
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)