简体   繁体   中英

How to convert Normalizer Transformation of Informatica into SQL query?

I have a table where I have a column REC_ORDER which has 20 occurences like REC_ORDER_1,REC_ORDER_2 upto REC_ORDER_20.After Normalizer Transformation,I get a single output column as REC_ORDER.I want to know how can I convert this Normalizer Transformation into SQL query.

You can create SQL like this -

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`

You can use the UNPIVOT clause of a SELECT like this:

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'
  )
);

The result set looks like:

| 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 |

See it in http://sqlfiddle.com/#!4/bf9cb/8/0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM