数据统计查询问题
大家节日好!我的表中,某一列N中存在几种相同字段比如:A、B、C,我想进行某一时段内同时进行A、B、C的分别统计查询。不知能否实现?如何写查询语句?请赐教,谢谢!以下是本人原来写的分别统计查询语句:
Dim sql As String
sql = "select * from 表 where N= '" & Trim(Combo1.Text) & "' and rq between #" & DTPicker1.Value & "# and #" & DTPicker2.Value & "# order by rq desc"
rs_feipin.CursorLocation = adUseClient
rs_feipin.open sql, conn, adOpenKeyset, adLockOptimistic
If Not rs_feipin.EOF Then
setgrid
setgridhead
displaygrid
If Combo1.Text = "A" Then
sum8 = 0
rs_feipin.MoveFirst
While Not rs_feipin.EOF
sum8 = sum8 + Val(rs_feipin.Fields(11).Value) ' A总量
rs_feipin.MoveNext
Wend
Text17.Text = Format(sum8, "##.0")
End If
If Combo1.Text = "B" Then
sum9 = 0
rs_feipin.MoveFirst
While Not rs_feipin.EOF
sum9 = sum9 + Val(rs_feipin.Fields(11).Value) 'B总量
rs_feipin.MoveNext
Wend
Text18.Text = Format(sum9, "##.0")
End If
If Combo1.Text = "C" Then
sum10 = 0
rs_feipin.MoveFirst
While Not rs_feipin.EOF
sum10 = sum10 + Val(rs_feipin.Fields(11).Value) 'C总量
rs_feipin.MoveNext
Wend
Text19.Text = Format(sum10, "##.0")
End If