插入一行后自动变成下表
此表数据量会很大 千万条记录计
6 个解决方案
#1
你这个和总共多少条数据没关系吧,你只需要处理增加的那一行和它下面那一行就ok了
#2
会中间插入数据,那么它后面的数据量可能会很大,处理起来就不好了吧
#3
额 我理解你的意思了 只要处理2条
#4
与2~count-1行合并
1
2 2
4 4
6 6
10
按时间排序,(row_number-1)/2为关联进行var操作
1
2
2
4
4
6
6
10
1
2 2
4 4
6 6
10
按时间排序,(row_number-1)/2为关联进行var操作
1
2
2
4
4
6
6
10
#5
#6
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]
#1
你这个和总共多少条数据没关系吧,你只需要处理增加的那一行和它下面那一行就ok了
#2
会中间插入数据,那么它后面的数据量可能会很大,处理起来就不好了吧
#3
额 我理解你的意思了 只要处理2条
#4
与2~count-1行合并
1
2 2
4 4
6 6
10
按时间排序,(row_number-1)/2为关联进行var操作
1
2
2
4
4
6
6
10
1
2 2
4 4
6 6
10
按时间排序,(row_number-1)/2为关联进行var操作
1
2
2
4
4
6
6
10
#5
#6
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]