asp中用Sql语句对多字段求和方法?
我写的是:<%setrs=server.createobject("adodb.recordset")sql="selectsun(debit)asdebit0,sun(...
我写的是:
<%
set rs=server.createobject("adodb.recordset")
sql = "select sun(debit) as debit0,sun(lender) as lender0 from account_book where c_name='"&request("c_name")&"' and lock='0'
and point<>'1' group by c_name order by adddate"
rs.open sql,conn,3,2
%>
<tr>
<td height="9" colspan="2" bgcolor="#F4F4F4"><div align="center"></div></td>
<td width="34%" bgcolor="#F4F4F4"><div align="center">本月小计</div></td>
<td width="20%" bgcolor="#F4F4F4"><div align="center"><%=rs("debit0")%></div></td>
<td width="20%" bgcolor="#F4F4F4"><div align="center"><%=rs("lender0")%></div></td>
<td bgcolor="#F4F4F4"><div align="center">
</div></td>
<td bgcolor="#F4F4F4"> </td>
</tr>
<%
rs.close
set rs = nothing
%>
--------------------------------------
系统错误提示是:
sun() 函数未定义,我用的是access 数据库!~ 展开
<%
set rs=server.createobject("adodb.recordset")
sql = "select sun(debit) as debit0,sun(lender) as lender0 from account_book where c_name='"&request("c_name")&"' and lock='0'
and point<>'1' group by c_name order by adddate"
rs.open sql,conn,3,2
%>
<tr>
<td height="9" colspan="2" bgcolor="#F4F4F4"><div align="center"></div></td>
<td width="34%" bgcolor="#F4F4F4"><div align="center">本月小计</div></td>
<td width="20%" bgcolor="#F4F4F4"><div align="center"><%=rs("debit0")%></div></td>
<td width="20%" bgcolor="#F4F4F4"><div align="center"><%=rs("lender0")%></div></td>
<td bgcolor="#F4F4F4"><div align="center">
</div></td>
<td bgcolor="#F4F4F4"> </td>
</tr>
<%
rs.close
set rs = nothing
%>
--------------------------------------
系统错误提示是:
sun() 函数未定义,我用的是access 数据库!~ 展开
2个回答
展开全部
sql = "select sun(debit) as debit0,sun(lender) as lender0 from account_book where c_name='"&request("c_name")&"' and lock='0'
改为:
sql = "select sum(debit) as debit0,sum(lender) as lender0 from account_book where c_name='"&request("c_name")&"' and lock='0'
改为:
sql = "select sum(debit) as debit0,sum(lender) as lender0 from account_book where c_name='"&request("c_name")&"' and lock='0'
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
求和是sum(),不是sun.
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询