oracle: sql statement added Total (union)

Transfer; https://blog.csdn.net/qq_43563538/article/details/90370925

The original table below:

 

All inquiries statement:

* BD_MARK_WHEIGHT_EQUIPMENT from the SELECT
1
Add Total:

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
如下图:

 

Note: The type and amount of data to be consistent.

Guess you like

Origin www.cnblogs.com/sharpest/p/11234247.html