Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: Help with removing dupes from a string with perl

by Herkum (Parson)
on Jul 09, 2009 at 13:11 UTC ( #778563=note: print w/replies, xml ) Need Help??


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

The SQL for looking up a unique column will roughly look like this(depending upon your database),

SELECT DISTINCT(JOBNAME), STATUS, TIMESTAMP, COMMENT FROM YOUR_TABLES +WHERE STATUS = ? ORDER BY TIMESTAMP DESC

Now you remove that loop for looking up individual job names.

Replies are listed 'Best First'.
Re^3: Help with removing dupes from a string with perl
by jrsimmon (Hermit) on Jul 09, 2009 at 14:06 UTC
    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).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://778563]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2018-07-18 18:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (393 votes). Check out past polls.

    Notices?