Page 1 of 1

Sort and extract records based on recent date

Posted: Mon Jun 28, 2010 9:17 am
by Sgiri1
Hi...I have a scenario where i have to sort the visit of a customer to a shop based on the date. I have to pick the latest three vists based on the date. I have the customer Id field and the date field. How do i extract the three records based on the recent date of visit and the customer id using datastage?

Posted: Mon Jun 28, 2010 9:26 am
by anbu
Use Sort stage to sort the input based on customer id and date on descending order. Set Create Key Change Column to true.

In transformer define counter stage variable

Code: Select all

If KeyChange=1 Then svCntr=1 Else svCntr=svCntr+1
Use the contraint in transformer

Code: Select all

svCntr <= 3

Posted: Mon Jun 28, 2010 11:21 pm
by Sgiri1
how do i initialize this value?

If KeyChange=1 Then svCntr=1 Else svCntr=svCntr+1

in the initial value of the stage variable???but it doesnt accept Keychange in the initial value.

Posted: Tue Jun 29, 2010 1:52 am
by ArndW
This is not the initial value of the stage variable, but the derivation.

Posted: Tue Jun 29, 2010 2:23 am
by ray.wurlod
The initial value can be any valid value for the data type. 0 suggests itself in this particular incarnation.