Hi guys,

7. how to get this output
i/p
col1,col2
101,a
102,b
103,c
104,d


o/p
col1,col2
101,d
102,c
103,b
104,a

Thanks

Answers were Sorted based on User's Feedback



Hi guys, 7. how to get this output i/p col1,col2 101,a 102,b 103,c 104,d o/p col1,col..

Answer / ankit gosain

Hi all,

For this scenario, construct a job like:


SeqFile------>Transformer------>Transformer----->SeqFile


Firstly, Change the execution mode of both the transformers
from default(parallel) to sequential.
Now, create a stage variable of varchar type in 1st
Transformer (say temp) & assign a default value to it
(say 'Ankit').
Now write in its derivation:
if temp='Ankit' then col2 else temp:',':col2

Now give the o/p derivation for the two columns as:
col1---col1
temp---col2

Now go to the 2nd Transformer & go to input tab and mention
the sorting on col1 as descending, create 3 stage variables
in it:
count1 of integer type with 0 as default value,
temp1 of varchar type with 'Ankit' as default value,
temp2 of varchar type.
then write in their derivation:

count1+1----------------------------------count1
if temp1='Ankit' then col2 else temp2-----temp1
temp1-------------------------------------temp2

Now write in O/p derivation of the columns:

col1-----------------------col1
field(temp2,',',count1)----col2

Now, do the sorting (ascending) on col1 in the o/p seqFile,
and drag & drop both the columns to the o/p link derivation
and you wil get the desired result.

If you have further queries, mail me on
ankitgosain@gmail.com

Cheers,
Ankit :)

Is This Answer Correct ?    7 Yes 1 No

Hi guys, 7. how to get this output i/p col1,col2 101,a 102,b 103,c 104,d o/p col1,col..

Answer / anil

1. Take a copy of the file in two links where id only in one link and value in another link.

2. For id link add a column generator for giving row number(Temp). Run this in sequential mode. Parition by Sort Merge (ascending)

3. For value link add a column generator for giving row number(Temp). Run this in sequential mode. Parition by Sort Merge (descending).

4. Now add look up between two columns with Temp as lookup. 

5. You will get the output as desired.

Is This Answer Correct ?    6 Yes 0 No

Post New Answer

More Data Stage Interview Questions

What are the areas of application?

0 Answers  


How to add zero "0" before record in a field?

4 Answers  


What are the important features of datastage?

0 Answers  


AGGREGATOR default datatype

0 Answers   CTS,


how can we join one oracle & flat files ?

2 Answers   ME,






How do you design PX Routines ?

1 Answers  


How can we run same job in 1 day 2 times

4 Answers   IBM,


What are the different type of jobs in datastage?

0 Answers  


insequential file 2header avaliable,and 100 records avaliable.how to skip the 2 headers and load 100 records target?

5 Answers  


Scenario : I have 2 jobs say job A and Job B with parameters x and y respectively. I need to create a sequence job. If we pass parameter x then Job A should run, If we pass parameter y then Job B should run, if we dont pass any parameter then Both Job A & B should run.

4 Answers   iGate, Thirdware,


how to get sum of sal based on dept_no and then sum of all sal irrespective of dept_no in same sql. output:- 10, 200(sum of sal for dept_no 10), 5000(sum of all sal)

0 Answers  


What all the types of jobs you developed?

0 Answers  


Categories