Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in SQL by (120 points)

I have input data like this

ABCLvlRef
2SZ46AV
0
2SZ46AV
2SZ46AV
1
934253-142
2SZ46AV
1
722979-002
2SZ46AV
2
708984-001
2SZ46AV
1
L16720-001
2SZ46AV
1
L37344-001
2SZ46AV
2
933274-001
2SZ46AV
2
L47720-001

I need a last column called ref output as shown in table which has the previous or last value of ref for each lvl  group

ABCLvlRef
Ref OutPut
2SZ46AV
0
2SZ46AV
NULL
2SZ46AV
1
934253-142
2SZ46AV
2SZ46AV
1
722979-002
2SZ46AV
2SZ46AV
2
708984-001
722979-002
2SZ46AV
1
L16720-001
2SZ46AV
2SZ46AV
1
L37344-001
2SZ46AV
2SZ46AV
2
933274-001
L37344-001
2SZ46AV
2
L47720-001
L37344-001

Please log in or register to answer this question.

Browse Categories

...