本人入坑不久,公司安排我改模型,时间很紧,自己去学习改来不及,所以请教各位大佬,原函数是通过计算得到yongneng,现在有了个需求,优先引用B表中的yongneng字段,如果为空,再通过原函数计算得到yongneng,这里好像要用case when,各位大佬们,应该怎么改?如下是原函数:
isnull(
CAST (
(
0.7143 * CAST (isnull(j008.TF002, 0) AS NUMERIC (18, 2))
+ 1.229 / 10000 * CAST (isnull(j002.TF001, 0) AS NUMERIC (18, 2))
+ 0.0341 * CAST (isnull(j008.TF004, 0) AS NUMERIC (18, 2))
+ 13.3 * CAST (isnull(j003.TF001, 0) AS NUMERIC (18, 2))
+ 1.4714 * CAST (isnull(j008.TF004, 0) AS NUMERIC (18, 2))
+ 1.4571 * CAST (isnull(j008.TF003, 0) AS NUMERIC (18, 2))
) AS NUMERIC (18, 2)
),
0
) AS yongneng
case when yongneng is null then 计算公式 else yongneng end as 一个字段