转自;https://blog.csdn.net/qq_43563538/article/details/90370925
原表见下图:
查询全部的语句:
SELECT * from BD_MARK_WHEIGHT_EQUIPMENT
1
添加合计:
SELECT * from BD_MARK_WHEIGHT_EQUIPMENT
UNION
SELECT '','合计','','','',to_char(sum(PLUS)),to_char(sum(REDUCE)),'',sum(plus) from BD_MARK_WHEIGHT_EQUIPMENT
1
2
3
如下图:
注意:数据类型和数量要保持一致。