首页 课程 师资 教程 报名

Java数据统计的实现方法

  • 2022-05-23 09:58:13
  • 3797次 动力节点

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

 

选你想看

你适合学Java吗?4大专业测评方法

代码逻辑 吸收能力 技术学习能力 综合素质

先测评确定适合在学习

在线申请免费测试名额
价值1998元实验班免费学
姓名
手机
提交