我有两列ActivityCount和ParentValue. 我创建了一个表达式:
ROUND((ActivityCount / ParentValue) / 100,16) * 100
但问题是它返回NULL某些列,我想NULL用0. 我似乎找不到答案。
我有两列ActivityCount和ParentValue. 我创建了一个表达式:
ROUND((ActivityCount / ParentValue) / 100,16) * 100
但问题是它返回NULL某些列,我想NULL用0. 我似乎找不到答案。
ISNULL(ParentValue) || (ParentValue == 0) ? 0 : ROUND(ISNULL(ActivityCount) ? 0 : ActivityCount / ParentValue / 100,16) * 100
ISNULL(ParentValue) || (ParentValue == 0)
? 0
: ROUND((ISNULL(ActivityCount)
? 0
: ActivityCount / ParentValue) / 100
, 16) * 100
如果ParentValuefield isNULL或 has Zero,您不必执行计算,因为您会遇到Divide by Zero错误。因此,只需返回0即可退出表达式。
如果ActivityCount字段为NULL,则在执行计算之前将其替换为零。
如果可能,我建议COALESCE在源查询上使用零值和计算替换 NULL 值。
试试下面...它会帮助你...
ISNULL(ROUND((ActivityCount / ParentValue) / 100,16) * 100) || (ROUND((ActivityCount / ParentValue) / 100,16) * 100)= "" ? 0 : ROUND((ActivityCount / ParentValue) / 100,16
我会说:
ISNULL(ActivityCount) || ISNULL(ParentValue) ? 0 : ROUND((ActivityCount/ParentValue)/100,16)*100
这样,您正在测试将导致 NULL 结果的最简单情况,而不是在条件中多次计算最终情况。
(话虽这么说,任何这些在技术上都可以工作。)