Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 对列值求和,并检查空条件_Sql_Sql Server_Sql Server 2008 - Fatal编程技术网

Sql 对列值求和,并检查空条件

Sql 对列值求和,并检查空条件,sql,sql-server,sql-server-2008,Sql,Sql Server,Sql Server 2008,我将此列转换为货币,在此基础上,我需要对此列的值求和,并需要设置一个验证,就像如果该列有空值,则必须返回零一样 select '$ '+ CONVERT(varchar,CONVERT(decimal(10,0),CONVERT(money, Amt_Value)),1) as [Amount] from Products 使用SUM和ISNULL select '$ '+ CONVERT(varchar,CONVERT(decimal(10,0),CONVERT(money, ISNUL

我将此列转换为货币,在此基础上,我需要对此列的值求和,并需要设置一个验证,就像如果该列有空值,则必须返回零一样

select '$ '+ CONVERT(varchar,CONVERT(decimal(10,0),CONVERT(money, Amt_Value)),1) as  [Amount]  from Products
使用SUM和ISNULL

select '$ '+ CONVERT(varchar,CONVERT(decimal(10,0),CONVERT(money, ISNULL(SUM(Amt_Value),0.00))),1) as  [Amount]  from Products