如何将informatica的normalizer转换为sql查询?

iugsix8n  于 2021-07-24  发布在  Java
关注(0)|答案(2)|浏览(362)

我有一个表,其中有一个列rec\u order,它有20个引用,比如rec\u order\u 1,rec\u order\u 2到rec\u order\u 20。在normalizer转换之后,我得到一个输出列rec\u order。我想知道如何将这个normalizer转换为sql查询。

mbskvtky

mbskvtky1#

你可以用 UNPIVOT a条款 SELECT 这样地:

create table demo(id number, n1 number, n2 number, n3 number, n4 number, n5 number);

insert into demo values (1, 45, 87, 96, 33, 17);
insert into demo values (2, 245, 287, 296, 233, 217);

commit;

select * from demo
unpivot (
  val
  for num in (
    n1 as '1',
    n2 as '2',
    n3 as '3',
    n4 as '4',
    n5 as '5'
  )
);

结果集如下所示:

| ID | NUM | VAL |
|----|-----|-----|
|  1 |   1 |  45 |
|  1 |   2 |  87 |
|  1 |   3 |  96 |
|  1 |   4 |  33 |
|  1 |   5 |  17 |
|  2 |   1 | 245 |
|  2 |   2 | 287 |
|  2 |   3 | 296 |
|  2 |   4 | 233 |
|  2 |   5 | 217 |

从中看到它http://sqlfiddle.com/#!4/bf9cb/8/0型

jckbn6z7

jckbn6z72#

您可以这样创建sql-

SELECT occurance1.id as id, occurance1.value1 from source_table occurance1
union all  
SELECT occurance2.id as id, occurance2.value2 from source_table occurance2
union all  
SELECT occurance3.id as id, occurance3.value3 from source_table occurance3
union all  
...
SELECT occurance20.id as id, occurance20.value20 from source_table occurance20`

相关问题