in reply to Re^2: Help with removing dupes from a string with perl
in thread Help with removing dupes from a string with perl

With DB2, using DISTINCT in that manner won't guarantee that you get the most recent result. DISTINCT will be evaluated before the ORDER BY clause and may not find the most recent record first. I'm not sure whether this behavior is standard among databases or not.

From the db2 doc:
When values match in the specified columns of two or more rows, the distinct operator retains only one of the duplicate rows in the result data set and discards the others. When duplicate rows are found, only the first row that is read during processing is retained. Because the order of rows is not guaranteed during processing, choose carefully when you select columns for the distinct operation.
To ensure you get the most recent occurrence, you'd probably need to use a temp table in the statement (at least that's how I've seen it done).
  • Comment on Re^3: Help with removing dupes from a string with perl