如何给空值赋值?
select sum(F_User_point) as gjpoint from TB_CDR where Calling_Station_Id='0411990005'
and Called_Station_Id like '00%'
and convert (varchar(10),convert(dateTime, h323_connect_Time),112) like '200803%'
如何在上面的语句里的gjpoint如果为空的话,就给gjpoint赋一个0的值?
[解决办法]
- SQL code
select ISNULL(sum(F_User_point),0) as gjpoint FROM ...
[解决办法]
select isnull(sum(F_User_point),0) as gjpoint from TB_CDR where Calling_Station_Id='0411990005'
and Called_Station_Id like '00%'
and convert (varchar(10),convert(dateTime, h323_connect_Time),112) like '200803%'
[解决办法]
ISNULL(sum(F_User_point),0) as gjpoint
[解决办法]
- SQL code
select 'gjpoint'=isnull(sum(F_User_point),0)from TB_CDRwhere Calling_Station_Id='0411990005' and Called_Station_Id like '00%' and convert (varchar(10),convert(dateTime, h323_connect_Time),112) like '200803%'
[解决办法]
- SQL code
select isnull(sum(F_User_point),0) as gjpoint from TB_CDR where Calling_Station_Id='0411990005' and Called_Station_Id like '00%' and convert (varchar(10),convert(dateTime, h323_connect_Time),112) like '200803%' --或者select case when sum(F_User_point) is null then 0 else sum(F_User_point) end as gjpoint from TB_CDR where Calling_Station_Id='0411990005' and Called_Station_Id like '00%' and convert (varchar(10),convert(dateTime, h323_connect_Time),112) like '200803%'
[解决办法]
解决就结贴。
[解决办法]
用函数isnull(col,0)
[解决办法]
[解决办法]