Home Page for the TeradataForum

Archives of the TeradataForum

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

  <Prev Next>  
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:-

     If emp_id not in ( supervisor's list)
            display empid
            Display empid
            CALL displayTree(emp_id)

     End if


Thanks and Regards,


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