我有使用聯合輸出向下結果的向下查詢,我想將輸出重新格式化爲下一個格式。如何更改查詢輸出
SELECT TO_CHAR(F.DATE, 'YYYY') YEAR,
F.FIELD,
ROUND((ROUND(SUM(F.INJECTION_ VOLUME)/120, 0)/1000), 2) INJECTION
FROM INJECTION F
GROUP BY TO_CHAR(F.DATE, 'YYYY'),
F.F_CD
HAVING TO_CHAR(F.DATE, 'YYYY') = '2013'
UNION
SELECT TO_CHAR(S.DATE, 'YYYY') YEAR,
S.FIELD,
ROUND((ROUND(SUM(S.PROD_VOLUME)/120, 0)/1000), 2) PRODUCTION
FROM PRODUCTION P
GROUP BY TO_CHAR(S.DATE, 'YYYY'),
S.FIELD
HAVING TO_CHAR(S.DATE, 'YYYY') = '2013'
ORDER BY 1
輸出
YEAR FIELD INJECTION
2013 FARM 122.35
2013 FARM 123.73
2013 DARM 59.99
所需的輸出
YEAR FIELD PRODUCTION INJECTION
2013 FARM 122.35 123.75
2013 DARM 59.99
是對齊的別名。謝謝。 – user3747520
你是什麼意思? t1和t2只是名字。他們可以是任何東西。 – Alisa
不是t的,是第二張桌子的S還是P ...... – user3747520