a b
20061105 10
20061106 12
20061107 13
20061108 14
20061109 15
表是这样的格式
算出每个日期之前的所有的b的值,所得结果如下
a b
20061105 10
20061106 22
20061107 35
20061108 49
20061109 64
--------------------------------------------------------------
创建表:create table test (a char(8),b int)
插入数据:insert into test4 values ('20061105',10)
insert into test4 values ('20061106',12)
insert into test4 values ('20061107',13)
insert into test4 values ('20061108',14)
insert into test4 values ('20061109',15)
sql语句:select a,b=(select sum(b) from test where a<=t.a) from test as t
新闻热点
疑难解答