Sort and extract records based on recent date

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
Sgiri1
Participant
Posts: 43
Joined: Sat Nov 08, 2008 10:58 pm
Location: Tambaram

Sort and extract records based on recent date

Post 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?
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post 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
You are the creator of your destiny - Swami Vivekananda
Sgiri1
Participant
Posts: 43
Joined: Sat Nov 08, 2008 10:58 pm
Location: Tambaram

Post 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.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

This is not the initial value of the stage variable, but the derivation.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The initial value can be any valid value for the data type. 0 suggests itself in this particular incarnation.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply