Re: GROUP BY

From: Gene Wirchenko <genew_at_ocis.net>
Date: Fri, 18 May 2007 12:42:09 -0700
Message-ID: <bvvr43d90cgbkk90k6edji5rgs2r725uar_at_4ax.com>


Marshall <marshall.spight_at_gmail.com> wrote:

[snip]

>What if 3) is empty?
>
>In that case, GROUP BY is equivalent to PROJECT!
>
>SQL obscures this fact, due to the templated nature of a SQL query.
>The 3)-empty case is:
> select b from R group by b
>which would just be simplified to:
> select b from R
>which is how you project in SQL already.

     Counterexample:

          create table r (a n(5), b n(5), c n(5))
          insert into r (a,b,c) values (1,2,1)
          insert into r (a,b,c) values (1,2,2)
          insert into r (a,b,c) values (1,2,3)
          insert into r (a,b,c) values (1,2,4)
          insert into r (a,b,c) values (1,2,5)

          select b from r group by b
          select b from r

The result of the first select is one row of b 2. The result of the second select is five rows of b 2.

[snip]

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:

     I have preferences.
     You have biases.
     He/She has prejudices.
Received on Fri May 18 2007 - 21:42:09 CEST

Original text of this message