名为" DED_LAYER_BENCHMARK_LP"的新列是从Excel IF函数创建的,如下所示。
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)
我想在SQL代码中编写上面的excel代码
答案 0 :(得分:0)
使用CASE
表达式:
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
答案 1 :(得分:0)
使用CASE
语句表达式。
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
文档链接:https://docs.microsoft.com/en-us/sql/t-sql/language-elements/case-transact-sql