sum求和的问题 asp
<%dimjj1,jj2,jj3setrs_kc=conn.execute("selectsum(fqty)aszsfromkcwherefno='"&rs_buy2("...
<%dim jj1,jj2,jj3
set rs_kc=conn.execute("select sum(fqty) as zs from kc where fno='"&rs_buy2("fno")&"'and ddk="&rs_buy2("ddk")&"")
If Not IsNumeric(jj1) Then
jj1=0
else
jj1=rs_kc("zs")
end if
rs_kc.close
set rs_kc=nothing
set rs_ck=conn.execute("select sum(fqty) as ck from thjl where fno='"&rs_buy2("fno")&"' and ddk="&rs_buy2("ddk")&"")
If Not IsNumeric(jj2) Then
jj2=0
else
jj2=rs_ck("ck")
end if
jj3=jj1-jj2
rs_ck.close
set rs_ck=nothing
%>
我的是一个求和问题,kc表没有空值 ,thjl有可能会有空值,所以不知道上面该怎么写才会显示空白而不报错
后来发现,数据库全是空的也正常,可以判断不是空的,但是值我设置了为空没有的话就是0,结果用:response.write a 或是 response.write b输出是一片空白, 什么也没有?
在此请教了,搞了半天也没有弄清楚是什么原因。
<%dim jj1,jj2,jj3
set rs_kc=conn.execute("select iif(IsNull(sum(fqty)), 0, sum(fqty)) as zs from kc where fno='"&rs_buy2("fno")&"'and ddk="&rs_buy2("ddk")&"")
jj1=rs_kc("zs")
rs_kc.close
set rs_kc=nothing
set rs_ck=conn.execute("select iif(IsNull(sum(fqty)), 0, sum(fqty)) as ck from thjl where fno='"&rs_buy2("fno")&"' and ddk="&rs_buy2("ddk")&"")
jj2=rs_ck("ck")
rs_ck.close
set rs_ck=nothing
jj3=jj1-jj2
%> 展开
set rs_kc=conn.execute("select sum(fqty) as zs from kc where fno='"&rs_buy2("fno")&"'and ddk="&rs_buy2("ddk")&"")
If Not IsNumeric(jj1) Then
jj1=0
else
jj1=rs_kc("zs")
end if
rs_kc.close
set rs_kc=nothing
set rs_ck=conn.execute("select sum(fqty) as ck from thjl where fno='"&rs_buy2("fno")&"' and ddk="&rs_buy2("ddk")&"")
If Not IsNumeric(jj2) Then
jj2=0
else
jj2=rs_ck("ck")
end if
jj3=jj1-jj2
rs_ck.close
set rs_ck=nothing
%>
我的是一个求和问题,kc表没有空值 ,thjl有可能会有空值,所以不知道上面该怎么写才会显示空白而不报错
后来发现,数据库全是空的也正常,可以判断不是空的,但是值我设置了为空没有的话就是0,结果用:response.write a 或是 response.write b输出是一片空白, 什么也没有?
在此请教了,搞了半天也没有弄清楚是什么原因。
<%dim jj1,jj2,jj3
set rs_kc=conn.execute("select iif(IsNull(sum(fqty)), 0, sum(fqty)) as zs from kc where fno='"&rs_buy2("fno")&"'and ddk="&rs_buy2("ddk")&"")
jj1=rs_kc("zs")
rs_kc.close
set rs_kc=nothing
set rs_ck=conn.execute("select iif(IsNull(sum(fqty)), 0, sum(fqty)) as ck from thjl where fno='"&rs_buy2("fno")&"' and ddk="&rs_buy2("ddk")&"")
jj2=rs_ck("ck")
rs_ck.close
set rs_ck=nothing
jj3=jj1-jj2
%> 展开
展开全部
空加0应该还是空
set rs_ck=conn.execute("select sum(fqty) as ck from thjl where fno='"&rs_buy2("fno")&"' and ddk="&rs_buy2("ddk")&"")
改成
set rs_ck=conn.execute("select sum(isnull(fqty,0)) as ck from thjl where fno='"&rs_buy2("fno")&"' and ddk="&rs_buy2("ddk")&"")
你的数据库是不是sqlserver?
--------------------------------------
那就用这个试试
set rs_ck=conn.execute("select sum(IIF(isnull(fqty),0,fqty)) as ck from thjl where fno='"&rs_buy2("fno")&"' and ddk="&rs_buy2("ddk")&"")
set rs_ck=conn.execute("select sum(fqty) as ck from thjl where fno='"&rs_buy2("fno")&"' and ddk="&rs_buy2("ddk")&"")
改成
set rs_ck=conn.execute("select sum(isnull(fqty,0)) as ck from thjl where fno='"&rs_buy2("fno")&"' and ddk="&rs_buy2("ddk")&"")
你的数据库是不是sqlserver?
--------------------------------------
那就用这个试试
set rs_ck=conn.execute("select sum(IIF(isnull(fqty),0,fqty)) as ck from thjl where fno='"&rs_buy2("fno")&"' and ddk="&rs_buy2("ddk")&"")
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询