高手帮忙啊!一语句
有下面的表:
WL Time number number1 number2
A 11 0 0 5
B 11 0 0 6
A 12 4 0 9
B 12 0 5 1
A 13 5 0 14
A 13 0 6 8
B 13 3 0 4
头两行是基础,后面的number2都为0,怎么写update语句,然后下面的每一行都按照WL不同,最后一个相同WL的number2+number-number1得到本行的number2如第三行5+4-0=9,第四行6-5=1,第五行:9+5=14。。。。急求。谢谢大家了
------解决方案-------------------- 没有办法用一个SQL删除,
只能这样
CREATE TABLE TMP_TABLE AS
SELECT WL,Time,number,number1,SUM(number2+number-number1) OVER (PARTITION BY WL ORDER BY TIME ROWS UNBOUNDED PRECEDING) AS number2
FROM UPDTEST
/
TRUNCATE TABLE YOURTABLE
/
INSERT INTO YOURTABLE
SELECT * FROM TMP_TABLE
/
DROP TABLE TMP_TABLE
/
------解决方案--------------------用游标循环吧