可能上面各位还没理会我的意思, D_M为搜索月份 D_Y为搜索年份
DIM D_M,D_Y,RS,Sqlstr
SqlStr="Select * From shop where month(Date)="&D_M&" and year(Date)="&D_Y&" Order By Date
Set RS=Server.CreateObject("ADODB.RECORDSET")
RS.Open SqlStr,Conn,1,1
IF RS.Eof And RS.Bof Then
Response.Write "<tr><td><font color=""#ff0000"">暂无月数据 </font></td></tr>"
Else
Response.Write "<tr bgcolor=""#0099CC""> <td><font color=""#000"">日期</font></td> <td><font color=""#000"">每日总值</font></td> </tr>"
Do While Not RS.Eof
If Not Response.IsClientConnected Then Response.end
Response.Write" <tr bgcolor=""#FFFFFF""> <td>"&RS("Date")&" </td> <td height=""25"">"&rs("rate")&" </td> </tr>"
RS.MoveNext
Loop
End IF
如我搜索的条件是2009年1月
现在显示出来的值是
本人改好了,如下:
DIM D_M,D_Y,RS,d_d,Sqlstr,Srate,RS2
SqlStr="Select * From shop where id in(select Min(id) from shop Group By Date ) and month(Date)="&D_M&" and year(Date)="&D_Y&" Order By Date '同日期显示一个数据
Set RS=Server.CreateObject("ADODB.RECORDSET")
RS.Open SqlStr,Conn,1,1
IF RS.Eof And RS.Bof Then
Response.Write " <tr> <td> <font color=""#ff0000"">暂无月数据 </font> </td> </tr>"
Else
Response.Write " <tr bgcolor=""#0099CC""> <td> <font color=""#000"">日期 </font> </td> <td> <font color=""#000"">每日总值 </font> </td> </tr>" 、
Do While Not RS.Eof
If Not Response.IsClientConnected Then Response.end
d_d=RS("Date") '获得循环日期
SqlStr="Select Sum(rate) as Srate From shop where day(Date)='"&day(d_d)&"' and month(Date)="&D_M&" and year(Date)="&D_Y&" "
Set RS2=Server.CreateObject("ADODB.RECORDSET")
RS2.Open SqlStr,Conn,1,1 '计算相同日期RATE之和
Response.Write" <tr bgcolor=""#FFFFFF""> <td>"&RS("Date")&" </td> <td height=""25"">"&rs2("Srate")&" </td> </tr>"
RS.MoveNext
Loop
End IF