专注Java教育13年 全国咨询/投诉热线:400-8080-105
首页 学习攻略 Java学习 Java数据统计的实现方法

Java数据统计的实现方法

更新时间:2022-05-23 09:58:13 来源:动力节点 浏览245次

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

 

提交申请后,顾问老师会电话与您沟通安排学习

免费课程推荐 >>
技术文档推荐 >>
返回顶部