Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

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

by mpeppler (Vicar)
on Jul 24, 2009 at 18:17 UTC ( #783072=note: print w/ replies, xml ) Need Help??


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

In Sybase you can use a a group by and a having clause, even without using any aggregates in the main query.

So something like

select jobname, status, timestamp, comment from the_table group by jobname having timestamp = max(timestamp)
should return something reasonable without the need for a sub-query.

Michael


Comment on Re^3: Help with removing dupes from a string with perl
Download Code
Re^4: Help with removing dupes from a string with perl
by tilly (Archbishop) on Jul 27, 2009 at 07:20 UTC
    For the record, I hate that "feature". What it means is that if you accidentally leave a field that is in the SELECT out of the GROUP BY, you'll introduce a join. Depending on the query, this join can be very large and very poorly behaved. Particularly if you've left joined to a large table.

    When I worked with Sybase I think I made this mistake every few months (with the left out field from a very large table), and inevitably didn't notice until my query had been grinding away for half an hour and the database was feeling the pressure. The database it usually happened on was used for production purposes, but luckily the consequences were only internally visible, and very few people were affected. Still it was my second greatest annoyance with Sybase. (They've since fixed my greatest annoyance at the time, which was page level locking.)

      I agree with you for the general case (and I use a development tool that will flag such omissions as a defect).

      But occasionally it is really useful - in particular for me as I write way more SQL (in stored procs, etc) than perl or any other client-side language these days.

      Michael

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://783072]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2014-09-22 09:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (185 votes), past polls