Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 26 Mar 2009 @ 10:33:01 GMT


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


Subj:   Sub query in case statement
 
From:   Anomy Anom

<-- Anonymously Posted: Thu, 26 Mar 2009 17:18 -->

HI guys,

I am getting error for this query. Could any one please help me.

Base table having these values.

     sel *  from hr_nonhr;

     ORG_CD          ORG_LEVEL

     7017            SUB_LOB
     00713-0001105   INTL_COST_CENTER
     1256995         SUB_LOB
     00645-0001105   INTL_COST_CENTER

If am writing the query with hard coded values for in clause its working fine. Here 7017 and 1256995

     sel
     case
       when org_CD in ( '7017','1256995')
     then 'Y'
     else 'N'
     END

     from hr_nonhr ;

I want it to be done dynamically. I want to extract ORG_CD column from hr_nonhr table where ORG_LEVEL is SUBLOB.

I am writing it in this way but getting error L

     sel
     case
       when org_CD in
     (sel ORG_CD  from hr_nonhr where ORG_LEVEL='SUB_LOB')
     then 'Y'
     else 'N'
     END

     from hr_nonhr ;

Is there any better way to do it dynamically?


Thanks



     
  <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: 27 Dec 2016