Percentile_Cont 函数抛出错误
Posted
技术标签:
【中文标题】Percentile_Cont 函数抛出错误【英文标题】:Percentile_Cont function throwing error 【发布时间】:2016-06-08 04:27:05 【问题描述】:我有这个查询,我试图在 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
时它工作正常,并且我有一个存储过程,其中将列作为参数输入工作得很好,所以我有点不知所措我在这里做错了。
【问题讨论】:
【参考方案1】:知道了。与其说是 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
然后很明显,我还需要按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
有点尴尬,我以前没看到过,但是疲惫的眼睛想念这些东西。
【讨论】:
以上是关于Percentile_Cont 函数抛出错误的主要内容,如果未能解决你的问题,请参考以下文章
什么是符号张量,为什么它们会抛出“使用 `steps_per_epoch` 参数”错误?
BigQuery:标准 SQL 和 PERCENTILE_CONT() 函数
在 Vertica 中创建 percentile_cont 作为聚合函数