首先我表SUM_REPANDMAINT, Table`s色譜柱名稱:如何在沒有重複條目的情況下在SQL中創建視圖?
ACTUAL_COST, PROJECTED_COST, TOTAL_PREV, TOTAL_PRESENT, 方差, VARIANCE_PER, LIMIT, COST_CENTER, ID, PLANT, BUDGET_YEAR, VERSION,
秒我已查看V_SUM_REPANDMAIN T, View`s列名:
USERNAME, CHARGE_CC, BUDGET_YEAR, 版, 植物, CHARGE_CC, PART_DESC, YEAR_DATE_USD,
這種圖像可以幫助理解這個問題:
我需要得到不重複的值。
注:YEAR_DATE_USD的總和是基於工廠和CHARGE_CC
我的查詢:
SELECT
A.ACTUAL_COST,
A.PROJECTED_COST,
A.TOTAL_PREV,
A.TOTAL_PRESENT,
A.VARIANCE,
A.VARIANCE_PER,
A."LIMIT",
A.COST_CENTER,
A.PLANT,
A.BUDGET_YEAR,
A."VERSION",
B.BUDGET_YEAR,
B."VERSION",
B.PLANT,
B.CHARGE_CC,
B.PART_DESC,
B.YEAR_DATE_USD
FROM
CMS.SUM_REPANDMAINT A,
CMS.V_SUM_REPANDMAINT B
WHERE
(A.BUDGET_YEAR = B.BUDGET_YEAR(+)) AND
(A."VERSION" = B."VERSION"(+)) AND
(A.PLANT = B.PLANT(+)) AND
(A.COST_CENTER = B.CHARGE_CC(+)) AND
(B.USERNAME = '[usr_name]')
us e group by爲您的唯一列 – JYoThI