In Teradata/SQL Server, how to get by SQL/BTEQ the hierarchical top parent?
- Head teacher is minimum id among all the teacher of the student.
- if student 10 has 3 teachers 1,8,9; teacher (id) 8 & 9 are also students, and student 8 & 9 will have teacher 1/ i.e. minimum teaches same as 10 has
Say for following input, how can we get the desired output?
Input:
Desired output: