第1个回答 2009-02-17
select name,price,weight from table
union
select '合计',(select sun(price) from table) as a,(select sun(weight) from table) as b
这个方法不错!
其实datagrid是可以控件行事件的,你可以把合计放在尾,再人工计算在行绑定事件里对尾行里面的lable控件等给值。就可以了。好多方法。
第2个回答 2009-02-17
修改你的sql语句就可以了,其他的不变。
select name,price,weight from table
union
select '合计',(select sun(price) from table) as a,(select sun(weight) from table) as b
说明:name,price,weight分别为你数据库里的产品、价钱、重量对应的字段名称,table为你要查询的表名称
第3个回答 2009-02-17
方法1
查询结果时加上合计行
一并显示到datagrid
方法2
查询结果在绑定前更新
比如你查询结果是dataset/datatable
那么自己在datatable中加上合计行(datatable.rows.add())
后绑定本回答被提问者采纳
第4个回答 2009-02-17
可以 选择datagrid,右键,智能标记,编辑模板,选 footer。