Skip to Content

Calculated Column Logic

Hi, I've been trying to write a SQL script in HANA Studio for creating a calculated column using the following pseudo code logic

If ("AUGBL_ORIG" is empty) { if ("AUGBL_BSEG_Vendor" is empty) { return "AUGBL_BSEG_CUSTOMER" } else { return "AUGBL_BSEG_Vendor" } } else { return "AUGBL_ORIG" } What would would be the best way to write the logic? Should i use CASE function or IF statements

Please help!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Feb 16, 2017 at 11:56 AM

    IF function would be efficient for that. In case "empty" means null, you an also use the ISNULL function instead of the "!=" operator which compares to '' in the following example:

    if("AUGBL_ORIG" != '', "AUGBL_ORIG", if("AUGBL_BSEG_Vendor" != '',"AUGBL_BSEG_Vendor","AUGBL_BSEG_CUSTOMER"))
    Add comment
    10|10000 characters needed characters exceeded