0

目前我正在做一个项目,我需要生成从表中提取的报告。下表如下

CURRENCY_A AMOUNT_A CURRENCY_B AMOUNT_B CURRENCY_C AMOUNT_C

我的期望是 (AMOUNT_A+AMOUNT_B+AMOUNT_C) 组的总和,按货币 USD :
EURO :
POUNDS :

是否可以单独在 oracle 中执行此输出?

4

1 回答 1

0
SELECT currency, SUM(total1) AS total FROM
(
SELECT currency_a AS currency, SUM(a_amount)  AS total1 FROM table1
GROUP BY currency_a
UNION ALL
SELECT currency_b, SUM(b_amount) AS total2 FROM table1
GROUP BY currency_b
UNION ALL
SELECT currency_c, SUM(c_amount) AS total2 FROM table1
GROUP BY currency_c
) T
GROUP BY currency
于 2013-08-27T08:08:18.480 回答