Case

Database

Case

could someone help me

between the need to query both the first "when" as in other "when" that exists with the same condition

select case when (a11.CAMPO = 1) then 'SP'
when (a11.CAMPO = 2) then 'SPINT'
when (a11.CAMPO = 3) then 'RJ'
when (a11.CAMPO = 4) then 'MG'
when (a11.CAMPO = 5) then 'SC'
when (a11.CAMPO = 6) then 'RS'
when (a11.CAMPO = 7) then 'CO'
when (a11.CAMPO = 8) then 'N'
when (a11.CAMPO = 9) then 'SE'
when (a11.CAMPO = 10) then 'NE'
when (a11.CAMPO in (1,2)) then 'SP'
when (a11.CAMPO in (7,8)) then 'CON'
when (a11.CAMPO in (1,2,3,4,5,6,7,8,9,10)) then 'TODOS'
when (a11.CAMPO in (1,2,3,4,6,7,8,9,10)) then 'TODOS SEM MINAS' end CustCol_27
from TABELA a11

Tks all
William Rosário
2 REPLIES
Teradata Employee

Re: Case

Hello,

Can you please explain what exactly you need to do?

Regards,

Adeel

Re: Case

Case is always evaluated and processed from the first, and the first true condition is what you always get as output. Besides once case statement can output only one attribute.

So in your case, you should probably move the last two conditions to two another case statements.