Hi all,
How can i implement this following logic in sql server :
I have 3 columns in a table say :
Distance Height Sequence
0.91 10 1
0.98 11 1
1.2 12 1
0 13 2
0.81 15 2
0.98 17 2
1.6 19 3
2.1 19.5 3
logic is as follows:
i should set offset value as 0.0
when new sequence starts, i should add offset value with previous row sequence value
eg:
set offset=0.0
offset=0.0+1.2(previous row value)=1.2
i should add the above offset value for values having sequence numbers as 2.
output for sequence having 2 will be :
Distance Height Sequence
1.2 13 2
2.01 15 2
2.18 17 2
now offset=1.2+2.18(previous row value)=3.38
above offset value, i should add for sequence numbers as 3
Distance Height Sequence
4.98 19 3
5.48 19.5 3
Overall my table should return the following output :
Distance Height Sequence
0.91 10 1
0.98 11 1
1.2 12 1
1.2 13 2
2.01 15 2
2.18 17 2
4.98 19 3
5.48 19.5 3
Thanks in advance.