Case statement with multiple else

General

Case statement with multiple else

I have requirement where i have write case statements for the below

 case when substr(bill_cyc_cd ,1,1) = 'B' and acct_typ_cd = 'C' then 'Y' else 'N' end

 else case when substr(bill_cyc_cd ,1,1) = 'G' then 'Y' else 'N'  end bill_cycle

Above syntax doesnt work and it looks like it will work only in SQL server.

What is the best way to accomplish this in Teradata

6 REPLIES

Re: Case statement with multiple else

case when substr(bill_cyc_cd ,1,1) = 'B' and acct_typ_cd = 'C' then 'Y' 
 when substr(bill_cyc_cd ,1,1) = 'G' then 'Y'
 else 'N'  end bill_cycle

Re: Case statement with multiple else

thanks it worked

Re: Case statement with multiple else

but I have another requirement

case when substr( pay_plan_ind ,1,1) = 'B' and acct_typ_cd = 'C' then 'D' else 'I' end

 else case when substr(bill_cyc_cd ,1,1) = 'G' then 'X' else 'U'  end bill_cycle

what is the best syntax to achieve the above in TD

Re: Case statement with multiple else

Can someone help me with the above problem

Re: Case statement with multiple else

Assigning two values for a single column will not be possible. There should be a condition(s) for either  I or U.

Teradata Employee

Re: Case statement with multiple else

Please have a look at following link, it explains the CASE statement:

http://www.info.teradata.com/htmlpubs/DB_TTU_14_00/index.html#page/SQL_Reference/B035_1145_111A/ch02...