0
如何重写以下查询,仅当它们不为空时,我将采用减号Correction
和Used
。检查值不为空
select Amount - Correction - Used
from CompList
where (CompID ='D999999' and Amount IS NOT NULL) ;
感谢您的帮助。
如何重写以下查询,仅当它们不为空时,我将采用减号Correction
和Used
。检查值不为空
select Amount - Correction - Used
from CompList
where (CompID ='D999999' and Amount IS NOT NULL) ;
感谢您的帮助。
使用COALESCE函数(返回第一个非空值):
select Amount - COALESCE(Correction, 0) - COALESCE(Used, 0) ....
您也可以使用函数IFNULL(场,0)。 它可能比COALESCE更快:你必须测试...