Question: Need help to write sql query Id is unique. NextID stores the noxt ID value. When NextID value is Null, there the path Ends. Input:
Need help to write sql query
Id is unique. NextID stores the noxt ID value. When NextID value is Null, there the path Ends.
Input:
ID NextID
1 5
2 Null
3 6
4 7
5 8
6 9
7 Null
8 Null
9 10
10 Null
Output:
a. 1 --> 5 --> 8
b. 2
C. 3 -->6 -->9 -->10
d. 4-->7
e. 8
Sample scripts:
INSERT Data VALUES ('1','5'), ('2','Null'), ('3','6'), ('4','7'), ('5','8'), ('6','9'), ('7','Null'), ('8','Null'), ('9','10'), ('10','Null')
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
