2016-06-08 170 views
1

我有這個疑問,我正在嘗試引入非靜態值到PERCENTILE_CONT:PERCENTILE_CONT函數拋出錯誤

SELECT perf2.REVIEW_PERIOD 
    , PERCENTILE_CONT(goalsASP.GOAL*.01) WITHIN GROUP (ORDER BY AVG_AMT ASC) ast75 
FROM repDB.TBL_PERFORMANCE perf2 JOIN 
     pz.CATEGORY C on perf2.DEPTCAT = C.id JOIN 
     repDB.TBL_GOALS_MATRIX goalsASP ON C.NAME = goalsASP.DIMENSION_Y 
             and perf2.REVIEW_PERIOD = goalsASP.SNAP_NAME 
             and goalsASP.DIMENSION_X = 'asp' 
GROUP BY perf2.REVIEW_PERIOD 

拋出的錯誤是:

ORA-30497: Argument should be a constant or a function of expressions in GROUP BY. 30497. 00000 - "Argument should be a constant or a function of expressions in GROUP BY."

這是一個查看,它工作正常時goalsASP.GOAL*.01.75.75和我有一個存儲過程中提供一個列作爲參數工作得很好,所以我有點在我在這裏做錯了一種損失。

回答

0

明白了。這不是Percentile_Cont的問題,這是一個正確分組的問題。

要解決我孤立goalsASP.GOAL

SELECT perf2.REVIEW_PERIOD 
    , goalsASP.GOAL 
FROM repDB.TBL_PERFORMANCE perf2 JOIN 
     pz.CATEGORY C on perf2.DEPTCAT = C.id JOIN 
     repDB.TBL_GOALS_MATRIX goalsASP ON C.NAME = goalsASP.DIMENSION_Y 
             and perf2.REVIEW_PERIOD = goalsASP.SNAP_NAME 
             and goalsASP.DIMENSION_X = 'asp' 
GROUP BY perf2.REVIEW_PERIOD 

那麼很明顯,我需要還GROUP BY goalsASP.GOAL

這樣,那麼,答案是:尷尬

SELECT perf2.REVIEW_PERIOD 
    , PERCENTILE_CONT(goalsASP.GOAL*.01) WITHIN GROUP (ORDER BY AVG_AMT ASC) ast75 
FROM repDB.TBL_PERFORMANCE perf2 JOIN 
     pz.CATEGORY C on perf2.DEPTCAT = C.id JOIN 
     repDB.TBL_GOALS_MATRIX goalsASP ON C.NAME = goalsASP.DIMENSION_Y 
             and perf2.REVIEW_PERIOD = goalsASP.SNAP_NAME 
             and goalsASP.DIMENSION_X = 'asp' 
GROUP BY perf2.REVIEW_PERIOD, 
     goalsASP.GOAL 

樣,我沒有之前看到的,但疲憊的眼睛錯過這個東西。