select * from table union select '','总计',(select sum(monry) from table)
用DainelLee(Iinexperience)的例子 table:(id varchar(20),name varchar(50),money int) 查询语句 (select * from table) union (select '','总记录',(select count(*) from table)) union (select '','总金额',(select sum(money) from table)) 注:另外可以用HAVING SUM(Money)>100进行分组
原表:TABLE1 A B C 1 100 200 1 999 888 2 666 666语句: SELECT SUM(B) AS Lentou, SUM(C) XiaoEr FROM TABLE1 UNION SELECT SUM(B) AS Expr1, SUM(C) AS Expr2 FROM TABLE1 GROUP BY A
结果: Lentou XiaoEr 666 666 1099 1088 1765 1754
select * from table) union (select '','总记录',(select count(*) from table)) union (select '','总金额',(select sum(money) from table))这是什么意思?
table:(id varchar(20),name varchar(50),money int)
select * from table
union
select '','总计',(select sum(monry) from table)
table:(id varchar(20),name varchar(50),money int)
查询语句
(select * from table)
union
(select '','总记录',(select count(*) from table))
union
(select '','总金额',(select sum(money) from table))
注:另外可以用HAVING SUM(Money)>100进行分组
如果是fastreport,到fastreport专题看看,里面有
A B C
1 100 200
1 999 888
2 666 666语句:
SELECT SUM(B) AS Lentou, SUM(C) XiaoEr
FROM TABLE1
UNION
SELECT SUM(B) AS Expr1, SUM(C) AS Expr2
FROM TABLE1
GROUP BY A
结果:
Lentou XiaoEr
666 666
1099 1088
1765 1754
union
(select '','总记录',(select count(*) from table))
union
(select '','总金额',(select sum(money) from table))这是什么意思?