Recursive logic
Posted: Sun May 22, 2011 9:58 pm
Hello,
I am trying to come up with a recursive SQL logic for the following input. The recursive logic has to be repeated for a subset of the same data, until it finds all possible combinations. C2 should be = C3 and the data has to be consecutive to get the expected result
Database is Teradata.
Example1:- (C - Column)
C1,C2,C3
k,1,2
k,2,3
k,3,4
Expected Output:-
C1,C2,C3
k,1,4
Example2:- (C - Column)
C1,C2,C3
k,1,2
k,3,4
k,4,5
k,6,7
k,7,8
Expected Output:-
C1,C2,C3
k,3,5
k,6,8
I am trying to come up with a recursive SQL logic for the following input. The recursive logic has to be repeated for a subset of the same data, until it finds all possible combinations. C2 should be = C3 and the data has to be consecutive to get the expected result
Database is Teradata.
Example1:- (C - Column)
C1,C2,C3
k,1,2
k,2,3
k,3,4
Expected Output:-
C1,C2,C3
k,1,4
Example2:- (C - Column)
C1,C2,C3
k,1,2
k,3,4
k,4,5
k,6,7
k,7,8
Expected Output:-
C1,C2,C3
k,3,5
k,6,8