Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Greetings to all!
Could you please tell me where the problem is with this syntax? Thank you so much, please accept my sincere gratitude
When ISPROJECTMAINORDER = '-1'
AND
ordercategory_code = '100'
AND
(sum(Total_cost_price_pbd) > 0.0), Total_cost_price_pbd,
(ISPROJECTMAINORDER = '-1'
AND
ordercategory_code = '100', TOTALNETAMOUNT * 0.65,
sum(SO_costprice)))
is this an interview question ? there is another post regarding this!!
Hi, it depends on where you want to use this expression. If it is in load script when loading data, it probably should go with prefix WHERE, not WHEN, and all sum functions should be covered with flags.
If it is in report level, if() function is best in this case, and you expression could look like this:
if(ISPROJECTMAINORDER = '-1' and ordercategory_code = '100' and (sum(Total_cost_price_pbd) > 0) , sum(Total_cost_price_pbd),
if(ISPROJECTMAINORDER = '-1' and ordercategory_code = '100', sum(TOTALNETAMOUNT * 0.65), sum(SO_costprice)))