Search code examples
sqloracle-databasecaseteradataconnect-by

How to convert connect by level in teradata


I was trying to convert the connect by level function of oracle to teradata. I have seen many examples over the net but this particular one is different,

 (SELECT 
     CASE LEVEL 
        WHEN 1 THEN 'MB'
        WHEN 2 THEN 'SB'
        ELSE 'TOTAL'
     END AS DRUG_SOURCE
 FROM
    DUAL 
 CONNECT BY LEVEL <= 3) RW  

Please let me know if you guys have any idea.


Solution

  • Hey I found the solution for this. Sorry I couldn't explain my question clearly.

    The below code would work exactly the way i wanted in teradata

    select 'MB' as DRUG_SOURCE from dual  
    union  
    select 'SB' as DRUG_SOURCE from dual  
    Union  
    select 'TOTAL' as DRUG_SOURCE from dual