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
新聞熱點
疑難解答