从oracle到配置单元的最大查询枢轴

disho6za  于 2021-06-24  发布在  Hive
关注(0)|答案(0)|浏览(205)

我正在尝试将我的oracle代码传输到具有最大代码透视的配置单元。示例代码如下:

LEFT OUTER JOIN
(SELECT * FROM
  (SELECT IDNUMBER, DESCRIPTION, SEQUENCE
  FROM
    (SELECT /*+PARALLEL(16)*/ RR.*,
      CASE
        WHEN LEAD(EXTRACTION_DATE) OVER (PARTITION BY IDNUMBER,SEQUENCE ORDER BY EXTRACTION_DATE) IS NULL
        THEN 'Y'
        ELSE 'N'
      END FLAG_CURRENT_RECORD
    FROM sample_table
    )
  WHERE FLAG_CURRENT_RECORD = 'Y' 
  AND EXTRACTION_DATE IS NOT NULL
  ) PIVOT (MAX(DESCRIPTION) FOR SEQUENCE IN(1 "COCO",2 "CATEGORY",3 "DESCRIPTION"))
  )KK
ON KK.IDNUMBER = XX.LINES_ID
select b.IDNUMBER,
concat_ws('',b.1) as COCO, 
concat_ws('',b.2) as CATEGORY, 
concat_ws('',b.3) as DESCRIPTION

    from
        (select id, code,
        collect_list(a.group_map['1']) as 1,
        collect_list(a.group_map['2']) as 2,
        collect_list(a.group_map['3']) as 3
        from 
                ( select
                IDNUMBER, DESCRIPTION, SEQUENCE
                map(SEQUENCE) as group_map from sample_table
                ) a group by a.IDNUMBER
        ) b;

目前我正在尝试使用组Map进行数据透视,但结果是:参数必须位于键/值对透视配置单元中。出什么事了?任何帮助都将不胜感激。谢谢你抽出时间。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题