首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

怎么给空值赋值

2012-01-21 
如何给空值赋值?select sum(F_User_point) as gjpoint from TB_CDR where Calling_Station_Id0411990005

如何给空值赋值?
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)
[解决办法]
探讨
解决了 谢谢各位了

[解决办法]
探讨
SQL codeselect 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_Stati…

热点排行