问一个很easy的问题,怎么样在vb数据库中求和?

jsnp 2002-05-10 12:21:38
我现在有个选修课的管理系统,我想知道怎么求每个人的总学分,每一个人有多条成绩记录,要把它们全都加起来,还不能加别人的!
我还想知道怎能在dbcombo中去掉重复的记录?就像用group by一样的效果!
谢谢!!
...全文
23 点赞 收藏 7
写回复
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
lihonggen0 2002-05-10
1 是Sql语句的应用

2.如下示例
Dim Comb_cx As New ADODB.Recordset
With Comb_cx
If .State = adStateOpen Then
.Close
End If
.ActiveConnection = adoCN
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockBatchOptimistic
.Source = "select distinct gbdq from cx_Htdj "
End If
.Open
End With
Combo2.Clear
If Comb_cx.RecordCount > 0 Then
Comb_cx.MoveFirst
Do While Not Comb_cx.EOF
Combo2.AddItem Comb_cx.Fields("gbdq") & ""
Comb_cx.MoveNext
Loop
End If
Comb_cx.Close
回复
Jameszht 2002-05-10
1.select student_id,sum(score) from table group by student_id
2.dbcombo 的數據源用distinct過濾掉重復值
回复
lihonggen0 2002-05-10
SELECT SUM(SL) AS SL, SUM(JE) AS JE, YWZH, STAFFCODE, SPMC, CKFPH, DATE,
DEPTCODE, PCDH, hth, ZL, wcbz, SPDM
FROM V_J_CKD_CC
GROUP BY YWZH, STAFFCODE, SPMC, CKFPH, DATE, DEPTCODE, PCDH, hth, ZL, wcbz,
SPDM
回复
dgz01 2002-05-10
distinct是用在语句当中,
回复
cmsoft 2002-05-10
select sum(name1) as name2 from tblname
回复
jsnp 2002-05-10
可是我用的是data控件,应该在那里设distinct呢?
回复
softrain 2002-05-10
SELECT 表1.id, Sum(aa+bb) AS cc
FROM 表1
GROUP BY 表1.id;
回复
发动态
发帖子

1180

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
社区公告
暂无公告