0

我正在使用 oracle fusion,我正在使用的应用程序之一(值集)不允许我在 select 语句中使用函数,并且 from 部分有 200 个字符的限制。

这个查询给了我我想要的,但我不能用选择的总和 -

SELECT SUM(d.ABS_UNITS) from PER_ALL_PEOPLE_F b, ANC_ABSENCE_PLANS_F_TL c, 
ANC_PER_ABS_PLAN_ENTRIES d
WHERE 
d.PERSON_ID = b.PERSON_ID
AND c.ABSENCE_PLAN_ID = d.ABSENCE_PLAN_ID
AND c.name = 'FMLA LWOP'
and d.start_date between '2017-04-02' and '2017-04-15'
AND b.PERSON_NUMBER = p_num

我也试过这个,但有字符限制问题 -

Select aa.bb from
(SELECT SUM(d.ABS_UNITS) as bb from PER_ALL_PEOPLE_F b, 
ANC_ABSENCE_PLANS_F_TL c, ANC_PER_ABS_PLAN_ENTRIES d
WHERE 
d.PERSON_ID = b.PERSON_ID
AND c.ABSENCE_PLAN_ID = d.ABSENCE_PLAN_ID
AND c.name = 'FMLA LWOP'
and d.start_date between '2017-04-02' and '2017-04-15'
AND b.PERSON_NUMBER = p_num
) aa

这种方法是我一直在尝试将总和放在 where 子句中的方法,但它没有返回任何内容。

Select
d.ABS_UNITS
FROM
PER_ALL_PEOPLE_F b, ANC_ABSENCE_PLANS_F_TL c, ANC_PER_ABS_PLAN_ENTRIES d
WHERE 
d.PERSON_ID = b.PERSON_ID
AND c.ABSENCE_PLAN_ID = d.ABSENCE_PLAN_ID
AND c.name = 'FMLA LWOP'
AND b.PERSON_NUMBER = pnum
and d.start_date between '2017-04-02' and '2017-04-15'
AND d.ABS_UNITS = (SELECT SUM(d.ABS_UNITS) from PER_ALL_PEOPLE_F b, 
ANC_ABSENCE_PLANS_F_TL c, ANC_PER_ABS_PLAN_ENTRIES d
WHERE 
d.PERSON_ID = b.PERSON_ID
AND c.ABSENCE_PLAN_ID = d.ABSENCE_PLAN_ID
AND c.name = 'FMLA LWOP'
and d.start_date between '2017-04-02' and '2017-04-15'
AND b.PERSON_NUMBER = pnum
)

任何意见和建议将不胜感激。

4

3 回答 3

0

我没有使用融合应用程序。
如果我不理解错误,您在选择中对字符限制和功能有限制。

考虑到您的字符限制,您的“where”子句很长。您可以对数据库级别的列和表使用 ALIAS 来缩短它。然后自定义您的查询。

于 2017-07-12T19:12:22.707 回答
0

感谢所有的投入,我真的很感激。我找到了一个解决方法,Oracle Fusion 在我正在使用的脚本语言中隐藏了未记录但可以通过 sql 找到的函数。非常沮丧,但感谢所有的反馈

于 2017-07-26T12:24:58.680 回答
-1

您不能在子句中使用聚合函数(例如SUM) ,因为物理上会限制行。您应在子句中聚合以在逻辑上限制输出。WHEREWHEREGROUP BY

于 2017-07-12T21:40:00.677 回答