Re: Group by & Distinct

From: Jerome Grandjanny <grandjan_at_ldg.bruyeres.cea.fr>
Date: 1996/06/04
Message-ID: <31B3EA34.C69_at_ldg.bruyeres.cea.fr>#1/1


Ken Johnson wrote:

<snip>

> select distinct v, sum(n) from test group by v;
> v n
> ----- --------
> x 5
> y 2
>
> If distinct was filtering out rows BEFORE the group by, the x total would have been 3, not
> 5. So evidently, distinct filters out the rows AFTER the group by (when they are all
> distinct anyway, so it has no additional effect)

Hello, I created the same table and try this :

 select v, sum ( distinct n ) from test group by v ;

and the result is :

V SUM(DISTINCTN)
- --------------

x              3
y              2

So, in this construct, DISTINCT filters out the rows BEFORE the GROUP BY.

                                        J.G. Received on Tue Jun 04 1996 - 00:00:00 CEST

Original text of this message