如何将Informatica的Normalizer Transformation转换为SQL查询?

How to convert Normalizer Transformation of Informatica into SQL query?

我有一个 table,其中有一列 REC_ORDER,它出现了 20 次,例如 REC_ORDER_1、REC_ORDER_2 直到 REC_ORDER_20.After 规范器转换,我得到一个输出列,因为 REC_ORDER.I 想知道如何将此规范器转换转换为 SQL 查询。

你可以这样创建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`

您可以像这样使用 SELECTUNPIVOT 子句:

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

中查看