Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

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.


Replies are listed 'Best First'.
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.


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2023-06-01 09:30 GMT
Find Nodes?
    Voting Booth?

    No recent polls found