Re: SQL question: GROUP BY and MAX

From: Paul Tiseo <tiseo.paul_at_mayo.edu>
Date: Sat, 21 Jul 2001 23:25:44 GMT
Message-ID: <MPG.1575b08d1ad51125989c3f_at_mayonews.mayo.edu>


In article <9eg8q3$np8$1_at_news.tue.nl>, hidders_at_REMOVE.THIS.win.tue.nl says...
> SELECT a
> FROM tabA
> GROUP BY a
> HAVING COUNT(*) = 5;
>
> This is equal to:
>
> SELECT DISTINCT a
> FROM tabA r1
> WHERE ( SELECT COUNT(*)
> FROM tabA r2
> WHERE r1.a = r2.a ) = 5;

        Would there/should there be performance differences, geenrally speaking? or, would most advanced db's SQL optimizers reduce it to the same operations? Thanks.

-- 

(Any opinions expressed are stricly mine only and not my employer's)
--------------------------------------------------------------------
Paul Tiseo, Intermediate Systems Programmer
Birdsall 3, Mayo Clinic Jacksonville
4500 San Pablo Rd, FL, 32224
tiseo.paul_at_mayo.edu -- (904) 953-8254
Received on Sun Jul 22 2001 - 01:25:44 CEST

Original text of this message