日期:2014-05-16 浏览次数:21104 次
Select [time],value1,value2 From(
Select [time],value1,sum(value1) OVER(PARTITION by rnum) as value2 From (
Select [time],value1,((row_number() OVER(Order by [time] DESC,value1))+1)/2 as rnum From (
select [time],value1 From m5_test
Union all
select [time],-value1 From(
select [time],value1,row_number() OVER(Order by [time] DESC) as rnum From m5_test
) as tb1 Where rnum>1
) tb2
) tb3
) tb4 Where value1>=0 Order by [time]