oracle 怎么样加一行做统计
发布网友
发布时间:2022-04-13 15:26
我来回答
共1个回答
热心网友
时间:2022-04-13 16:56
select t.*
from (SELECT '1' AS A, '1' AS B, '1' AS C
FROM DUAL
UNION ALL
SELECT '2' AS A, '2' AS B, '2' AS C
FROM DUAL
UNION ALL
SELECT '3' AS A, '3' AS B, '3' AS C
FROM DUAL
UNION ALL
SELECT '4' AS A, '4' AS B, '4' AS C
FROM DUAL
UNION ALL
SELECT '5' AS A, '5' AS B, '5' AS C
FROM DUAL) t
UNION
select '合计:' || to_char(sum(f.A)),
'合计:' || to_char(sum(f.B)),
'合计:' || to_char(sum(f.C))
from (SELECT '1' AS A, '1' AS B, '1' AS C
FROM DUAL
UNION ALL
SELECT '2' AS A, '2' AS B, '2' AS C
FROM DUAL
UNION ALL
SELECT '3' AS A, '3' AS B, '3' AS C
FROM DUAL
UNION ALL
SELECT '4' AS A, '4' AS B, '4' AS C
FROM DUAL
UNION ALL
SELECT '5' AS A, '5' AS B, '5' AS C
FROM DUAL) f
追问这样相当于sql执行了两遍