ritz dieheart
ritz dieheart

Reputation: 1

if statement in HANA information models

I have created three new calculated columns based on existing flag fields A,B, C.

and logic is

1) if flag fields (A or B or C) equals to 'X' Field 1 will be 'X'.

2) if flag fields (A and B) or (B and C) or (A and C) equals to 'X' field 2

3) if flag fields (A and B and C) = 'X' Field 3.

Could you please suggest the code for HANA.

Upvotes: 0

Views: 6477

Answers (1)

Eralper
Eralper

Reputation: 6612

Please check following CASE statements

select
*,
case when A = 'X' or B = 'X' or C = 'X' then 'X' else NULL end as Field1,
case when (A = 'X' and B = 'X') or (A = 'X' and C = 'X') or (B = 'X' or C = 'X') then 'X' else NULL end as Field2,
case when A = 'X' and B = 'X' and C = 'X' then 'X' else NULL end as Field3
from Flags;

Upvotes: 1

Related Questions