Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

A new column named "DED_LAYER_BENCHMARK_LP" is created from Excel IF function as shown below.

DED_LAYER_BENCHMARK_LP =  =if(_DataCell_ULFBL<=_InputCell_Deductible,

_DataCell_Original_Bench_LP_r0000_c0000,0) + 
if(_DataCell_ULFBL + _InputCell_Layer_r0000_c0000 <= _InputCell_Deductible,
    _DataCell_Original_Bench_LP_r0001_c0000, 0)

I want write the above excel code in SQL code

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
165 views
Welcome To Ask or Share your Answers For Others

1 Answer

Use a CASE expression:

CASE WHEN _DataCell_ULFBL <= _InputCell_Deductible
     THEN _DataCell_Original_Bench_LP_r0000_c0000
     ELSE 0 END +
CASE WHEN _DataCell_ULFBL + _InputCell_Layer_r0000_c0000 <= _InputCell_Deductible
     THEN _DataCell_Original_Bench_LP_r0001_c0000 ELSE 0 END AS DED_LAYER_BENCHMARK_LP

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...