Selecting max Date Record

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
iwin
Premium Member
Premium Member
Posts: 99
Joined: Mon Apr 11, 2005 9:20 pm

Selecting max Date Record

Post by iwin »

Hi,
I have two records source with same keys but the only difference is the Date field. And i need to pick the record which has a max date and ignore the other record.

Please advice me.

Thanks In Advance
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

What datatype and format is your date column? If it is a string in the form of yyyy-mm-dd then a simple string comparison will suffice.
rwierdsm
Premium Member
Premium Member
Posts: 209
Joined: Fri Jan 09, 2004 1:14 pm
Location: Toronto, Canada
Contact:

Re: Selecting max Date Record

Post by rwierdsm »

Assuming that the source is a flat file, run the data through an aggregator, grouping by all the fields except the date field then select the max date. Only one row will survive the aggregation.

If the source is an RDBMS, you could do something similar using a group by in the SQL.

HTH,

Rob W
Rob Wierdsma
Toronto, Canada
bartonbishop.com
iwin
Premium Member
Premium Member
Posts: 99
Joined: Mon Apr 11, 2005 9:20 pm

Post by iwin »

Hi,
It worked by giving group by in SQL.

Thanks Guys
Post Reply