access數據庫統計最近12個月(每個月)數據
廣告:
<%
dim a
' group by month(date)
' 叁照 http://www.cnblogs.com/Fooo/p/3435687.html
sql=" SELECT top 12 cstr(year(actiondate))+'年',cstr(month(actiondate))+'月',count(id),sum(zonger) FROM mvc_order group by year(actiondate),month(actiondate) order by 1 desc"
'最近一月總
totalren=0
totalzonger=0
rs.open sql,conn,1,1
do while not rs.eof
totalren=rs(2)
totalzonger=rs(3)
totalevery=0
totalevery=totalzonger/totalren %>
<tr <%=css%>>
<td><%=rs(0) & " " & rs(1)%></td>
<td></td>
<td></td>
<td></td>
<td><%=Formatnumber(totalren,0,-1)%></td>
<td><%=Formatnumber(totalzonger,2,-1)%></td>
<td></td>
<td></td>
<td><%=Formatnumber(totalevery,2,-1)%></td>
</tr>
<%
rs.movenext
loop
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
廣告: