create a job to get the previous row salary for the current row.if there is no previous row exists for the current row,then the previous row salary should be displayed as null?
empid   salary   previoussalary
10      1000     null
20      2000     1000
30      3000     2000      
40      4000     3000

Answer Posted / venkata ramana

Input:Seq file
empid,salary
10,1000
20,2000
30,3000
40,4000

Sequential file stage--->Trasformar Stage---->Dataset Stage

Transformation Logic:

InputTab-->Partition--> select "same"---> Select "Perform Sort" on key "empid"

Declaration of Stage Variables:

PrevSal Varchar ( Set right Intial value ' ' i.e Null value)
CurSal Varchar

Derivation Stage Variables
---------- ---------------
CurSal PrevSal
Linkname.Salary CurSal

Derivation Column name
--------- -----------
Linkname.empid empid
Linkname.Salary Salary
PrevSal previoussalary

Output DataSet result:-
empid salary previoussalary
10 1000 null
20 2000 1000
30 3000 2000
40 4000 3000

Is This Answer Correct ?    7 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you schedule or monitoring the job?

661


How to RD using transformer?

854


What are the types of containers?

680


Differentiate between datastage and datastage tx?

588


How to implement complex jobs in data stage?

612






On which Dimension Table you implemented SCD Type in your Project

1574


What is the differentiate between data file and descriptor file?

859


what is the use of materialized view?

954


What is the difference between passive stage and active stage?

818


Define Routines and their types?

618


Difference between server jobs & parallel jobs?

644


i have a job with 3 possibiliies finish with ststus ok abbort warning how do you handle these 3 in job sequence? explain the situation where you have appiled scd in your project? chandu

2268


What is the roundrobin collector?

635


How to read multiple files using a single datastage job if files have the same metadata?

735


What are the functionalities of link partitioner?

614