ASP中SQL查询A值-B值(B值为一个合计数),为什么当B值为空时其结果也为空呢?
在ASP的页面中,代码这么写htbh=request.QueryString("htbh")
set rs_1 = server.createobject("adodb.recordset")
sql = "SELECT a.htbh, a.gys, a.htnr, a.htj, Sum(b.fkje) AS fkje_hj, a.htj-Sum(b.fkje) AS sc_sqje FROM htsx AS a LEFT JOIN fkmx AS b ON a.htbh=b.htbh GROUP BY a.htbh, a.gys, a.htnr, a.htj HAVING a.htbh='"& htbh &"'"
rs_1.open sql,conn,1,1
页面输出:
<%=rs_1("sc_sqje")%>
当表fkmx尚未有记录时,则a.htj-Sum(b.fkje)其值应为a.htj的值,但为什么是没有(空)值了呢?
如何才使Sum(b.fkje)为空时就当该值为0来进行计算~~~谢谢!~