Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select id,
- number_sequ,
- startvalue
- lead(startvalue,1,0) over (partition by id order by number_sequ) AS End_value
- from mytable
- id number_sequ startvalue End_value
- ---- ----- ---------- -----------
- AAA 1 30 20
- AAA 2 20 10
- AAA 4 10 15
- AAA 5 15 0
- BBB 1 12 23
- BBB 3 23 34
- BBB 4 34 0
- id number_sequ startvalue End_value
- ---- ----- ---------- -----------
- AAA 3
- BBB 2
- INSERT INTO mytable (id,number_sequ,startvalue)
- select id ,number_sequ ,'0' from mytable where (some condition to specify missing data)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement