更新时间:2022-05-23 09:58:13 来源:极悦 浏览3666次
Java数据统计的实现方法是什么?极悦小编来告诉大家。
1. 创建对应的表
CREATE TABLE "NETPORTVIEW"
("GRP" CHAR(5),
"VIEWDATE" CHAR(10),
"PORT" CHAR(4),
"NUM1" NUMBER(10,2),
"NUM2" NUMBER(10,2),
"NUM3" NUMBER(10,2)
)
2. 插入数据
insert into netportview (GRP, VIEWDATE, PORT, NUM1, NUM2, NUM3)
values ('pvc ', '2011-02-12', '5200', 50000.00, 1000.00, 10.00);
insert into netportview (GRP, VIEWDATE, PORT, NUM1, NUM2, NUM3)
values ('pvc ', '2011-02-03', '6969', 100000.00, 2000.00, 10.00);
insert into netportview (GRP, VIEWDATE, PORT, NUM1, NUM2, NUM3)
values ('pvc ', '2011-02-09', '6969', 50000.00, 1000.00, 10.00);
insert into netportview (GRP, VIEWDATE, PORT, NUM1, NUM2, NUM3)
values ('pvc ', '2011-02-01', '5200', 80000.00, 2000.00, 8.00);
3. 查询
select * from (
select t.grp,t.viewdate,t.port,t.num1, t.num2, t.num3 from netportview t
union
select '小计' as GRP,null,t.port,sum(num1),null,sum(num3) from netportview t group by t.grp,port
union
select '总计' as GRP,null,'9999',sum(num1),null,sum(num3) from netportview t
)
order by port,viewdate
0基础 0学费 15天面授
Java就业班有基础 直达就业
业余时间 高薪转行
Java在职加薪班工作1~3年,加薪神器
工作3~5年,晋升架构
提交申请后,顾问老师会电话与您沟通安排学习