发布网友
共1个回答
热心网友
我建了测试的表如下:create table tbl (
wl_time timestamp ,
rzsl decimal(4,2)
) 输入了几条数据:insert into tbl values('2010-11-01 23:00:00',5.91);
insert into tbl values('2010-11-02 00:00:00',5.93);
insert into tbl values('2010-11-02 01:00:00',5.93);
insert into tbl values('2010-11-02 02:00:00',5.86);
insert into tbl values('2010-11-02 03:00:00',5.91);
insert into tbl values('2010-11-02 04:00:00',5.97);
insert into tbl values('2010-11-02 05:00:00',5.95); 写的SQL如下: select t1.wl_time, t1.rzsl, sum(t2.rzsl) from tbl t1, tbl t2where t1.wl_time >= t2.wl_time and to_char(t1.wl_time,'YYYY-MM_DD')=to_char(t2.wl_time,'YYYY-MM_DD') group by t1.wl_time,t1.rzsl order by t1.wl_time 运行结果如下: 不知道这是不是你要的结果,供参考。