connect to ksdbs;
drop table ks.studen;
create table ks.studen
( opname char(3) not null with default '',
studentcode int not null with default 0,
studentname char(8) not null with default '',
subject char(8) not null with default '',
money DECIMAL(19,4) not null with default 0
)
in tx_data_tbs;
insert into ks.studen values ('001',1,'郭静','数学',200);
insert into ks.studen values ('001',2,'黄蓉','历史',300);
insert into ks.studen values ('002',1,'老顽童','语文',200);
insert into ks.studen values ('002',1,'王重阳','政治',100);
执行以下命令:
db2 "select opname as '录入员',sum(studentcode) as '报名人数',sum(money) as '收费金额' from ks.studen group by opname "
结果:
录入员 报名人数 收费金额
------ ----------- ---------------------------------
001 3 500.0000
002 2 300.0000