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

Explain how a source file is populated?

766


What is the difference between in process and inter process?

672


State the difference between an operational datastage and a data warehouse?

609


project Steps,hits, Project level HArd things,Solved methods?

1638


what is ds administrator used for?

722






What is staging variable?

624


How will you load you daily/monthly jobs datas in to Fact and Dimension table using datastage.

2993


What are the various kinds of containers available in datastage?

567


what is the custome stage in datastage? how can we impliment that one? plz tell me

1912


Can you implement SCD2 using join, transformer and funnel stage?

1091


Difference between ‘validated ok’ and ‘compiled’ in data stage?

677


How do you schedule or monitoring the job?

671


How the ipc stage work?

678


In a batch if a job fails in between and you want to restart the batch from that particular job and not from the scratch then what will you do?

602


Define oconv () and iconv () functions in datastage?

883