Quantcast
Channel: SCN : Unanswered Discussions - SAP HANA and In-Memory Computing
Viewing all articles
Browse latest Browse all 4343

Case statement/If condition in new calculated column

$
0
0

Hi All,

 

I have a SQL Script calc view that selects set of fields and I need to create a new calculated column like this -

If In_Param = US

     if (isNull(Var1))

          Var2

     else

          Var1

else

     Var1

endif   

 

the SQL script calc view is as shown below and i try to add it but get the error as highlighted in the below script..

 

Queries:

Could you please help me please??

1. can i use input parameter In_Param for condition? If no, then what is the alternative to achieve this

2. can i have nested Ifs and/or case statement?

 

error:

error.JPG

 

Script

BEGIN /********* Begin Procedure Script ************/

 

BEGIN

  

V_TEMP =

SELECT * from <table>

.....

...........

..................

<Filter logic here>

..........................

 

var_out1 = APPLY_FILTER (:V_TEMP,:v_flt_id);

 

var_out =

SELECT "J_3AEAN11",

  "MATNR",

  "VBELN",

  "POSNR",

  "J_3ASIZE",

  "MAKTX",

  "ARTNR",

  "WERKS",

  "NAME1",

  "AUART",

  "LIFSK",

  "CSTFLD02",

<error here> 

CASE WHEN :In_Param = 'US' THEN CASE "VAR1" IS NULL THEN "VAR2" ELSE "VAR1" END

  ELSE "VAR2" END  AS "CM_VAR",

  sum("MENGE") AS "MENGE",

  sum("J_3ARESM") AS "J_3ARESM"

FROM :var_out1

 

 

END /********* End Procedure Script ************/




Viewing all articles
Browse latest Browse all 4343

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>