标签: sql sql-server tsql
当Null为结果时,如何将下面的SQL语句更改为显示0而不是Null?
SELECT cast (sum([ColumnA]) as DECIMAL(18,0)) AS [Weight] FROM [DB1].[dbo].[Tabel1]
答案 0 :(得分:0)
这应该有效:
SELECT cast(COALESCE(sum([ColumnA]), 0) as DECIMAL(18,0)) AS [Weight] FROM [DB1].[dbo].[Tabel1]