更新时间:2023-01-31 15:48:24
您好,
您可以使用ISNULL
SQL的功能。ISNULL
函数将使用您指定的值替换空值。
请参阅以下文章,了解有关ISNULL $的更多信息c $ c>功能。
ISNULL-MSDN [ ^ ]
Hi,
you can make use ofISNULL
function of SQL.ISNULL
function will replace the null value with the value you specify.
refer below article for more onISNULL
function.
ISNULL-MSDN[^]
--Example,
SELECT ISNULL(col1, 0), ISNULL(col2, 0), ISNULL(col3, ''), ISNULL(col4, GETDATE()) FROM TableName
我也建议使用*
在选择查询中不是好习惯。指定列名。
希望它有所帮助。
also, i suggest, using "*"
in select query is not good practice. specify the column names.
hope it helps.
使用ISNULL关键字使空列返回值为0. br />
例如:
SELECT ISNULL(column1,0),ISNULL(column2,0)FROM TABLENAME
干杯。 :)
Make use ISNULL keyword to make null columns return value as 0.
For ex:
SELECT ISNULL(column1,0) , ISNULL(column2,0) FROM TABLENAME
cheers. :)
选择Nvl(ColName,0)作为ColNAme来自TabName
ColName:列名,如果它是Null则将显示0,否则将显示其值。
TabName:表名称
Select Nvl(ColName,0) As ColNAme From TabName
ColName: Column Name, if it is Null then 0 will be displayed else its value will be displayed.
TabName: Table Name