sum()在SQL语句中怎么写

现想用c语言编程实现在面板中显示数据库中的内容,并在最后一行字段名为金额中显示出此字段名下的总金额,也就是怎么把这两个SQL语句"select * from table1","select sum([总价]) from table1 "放到一起来实现这个功能啊,谢谢大家

第1个回答  2010-12-14
select a,b,c,d... from tbl
union all
select null as a,null as b,null as c sum(d) as d... from tbl

意图很简单,就是把除了要sum之外的各个字段置空,然后把总计的那个字段值算出来作为最后一条记录。当然,其他字段的空,在你的程序中需要处理,否则可能出异常。
第2个回答  2010-12-19
select sum([总价]) ,* from table1 group by 总价,字段 内置函数要用group by
第3个回答  2010-12-14
select *,sum([总价]) as [总价] from table1本回答被网友采纳
第4个回答  2010-12-14
select * from table1"
union all
"select sum([总价]) from table1
相似回答