EBS: Report Builder 的公式程序中不支持over()分组

在ORACLE Report Builder 10G中function功能程序中不支持 ROW_NUMBER() OVER(PARTITION BY XXXX, YYY  ORDER BY ZZZ,JJJ ) 

的分组函数。 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
-- 2021/11/22,add: 按工單分組,按最新異常原因降序排序.然後返回最新一個異常代碼
-- 在Report Builder10G中不支持此寫法
select flex_value from (
SELECT x.flex_value,
       row_number() over(partition by nwj.wip_entity_id order by nwj.allocation_id desc) as rn
  --into v_exception
FROM   wip_operations wo
      ,nj.nj_wip_joexception nwj
      ,(select a.flex_value ,a.description
from fnd_flex_values_vl a ,fnd_flex_value_sets b
where a.flex_value_set_id = b.flex_value_set_id
and b.flex_value_set_name = 'WIP_JOEXCEPTION'
and a.enabled_flag = 'Y') x
 WHERE wo.wip_entity_id = nwj.wip_entity_id
   AND wo.department_id = nwj.exception_depart_id
   --and  wo.quantity_in_queue=1
   and  wo.quantity_in_queue>=1
   and  wo.quantity_completed=0
   AND wo.wip_entity_id =:wip_entity_id
   and nwj.jo_exception=x.DESCRIPTION  
  -- and rownum=1
 --ORDER BY nwj.allocation_id desc
  ) m1 where rn =1  ;
   
-- 環境: PROD
-- 2021/11/22,add: 按工單分組,按最新異常原因降序排序.然後返回最新一個異常代碼
-- 因在Report Builder10G中不支持ROW_NUMBER OVER()寫法  
-- 改為以下方式
SELECT x.flex_value
  into v_exception
FROM   wip_operations wo
      ,nj.nj_wip_joexception nwj,
      (select nwj3.wip_entity_id, max(nwj3.allocation_id) as allocation_id
        from nj.nj_wip_joexception  nwj3
         where nwj3.creation_date> add_months(sysdate,-36)
      group by nwj3.wip_entity_id ) nwj2
      ,(select a.flex_value ,a.description
        from fnd_flex_values_vl a ,fnd_flex_value_sets b
        where a.flex_value_set_id = b.flex_value_set_id
        and b.flex_value_set_name = 'WIP_JOEXCEPTION'
        and a.enabled_flag = 'Y') x
 WHERE wo.wip_entity_id = nwj.wip_entity_id
   AND wo.department_id = nwj.exception_depart_id
   --and  wo.quantity_in_queue=1
   and  wo.quantity_in_queue>=1
   and  wo.quantity_completed=0
   AND wo.wip_entity_id =:wip_entity_id
   and nwj.jo_exception=x.DESCRIPTION  
   AND nwj.allocation_id = nwj2.allocation_id
   and nwj.wip_entity_id = nwj2.wip_entity_id
   and rownum=1;
   

  

 

posted @   samrv  阅读(75)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示