Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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

by Herkum (Parson)
on Jul 09, 2009 at 13:11 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://778563]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-04-26 07:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found