asp中如何累计数据?
我想在库里取出4个单位,把这四个单位的运输车辆累计起来变成月累计字段,如下代码是我写的,可是计算车来的却是每个单位的累计,我想要的是四个单位一起的。
帮忙看看如下代码:
<%rs_jhsz.movefirst%> <%for i=1 to num_jhsz%>
<% '计算月累计运行车辆
set rs1_jhsylj = server.createobject( "ADODB.Recordset ")
sql1_jhsylj= "select sum(yield) as jhsylj1 from data_jhsz where unit= ' "&rs_jhsz( "unit ")& " ' and year(sc_day)= ' "&year(session( "sc_date "))& " 'and month(sc_day)= ' "&month(session( "sc_date "))& " 'and day(sc_day) <= ' "&day(session( "sc_date "))& " ' "
rs1_jhsylj.open sql1_jhsylj,conn,3,2
%>
<td align= "middle " width= "18% " height= "29 "> <font size= "2 "> <%=rs1_jhsylj.fields( "jhsylj1 ")%> </font> </td>
<%rs_jhsz.movenext
next%>
------解决方案--------------------把数据库表结构给出来吧
------解决方案--------------------select sum(yield) as xx from data_jhsz
------解决方案--------------------因为单位唯一