Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Fri, 19 Nov 2004 @ 10:52:21 GMT


     
  <Prev Next>  
<<First
<Prev
Next> Last>>  


Subj:   Recursive queries
 
From:   Agarwal, Rachana

Hi All,

Can we write recursive queries in Teradata.

I have a requirement wherein I need to display Hierarchy tree for a supervisor.

The table would have 2 fields empid and supervisor Id:-

Sample Data

     Employee-Id    Supervisor-id
     1              ---
     2              1
     3              2
     4              2
     5              4
     6              4

I want it to be implemented in a single query ..

Below is a pseudocode for recursive solution to same:-

     DisplayTree(Supervisor_id)
(
     If emp_id not in ( supervisor's list)
            display empid
            exit
     Else
            Display empid
            CALL displayTree(emp_id)

     End if

     )

Thanks and Regards,

Rachana



     
  <Prev Next>  
<<First
<Prev
Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023