Re: GROUP BY
Date: Sat, 19 May 2007 14:08:04 GMT
Message-ID: <8xD3i.7648$Qz.5190_at_trndny09>
"Marshall" <marshall.spight_at_gmail.com> wrote in message
news:1179513166.858089.73940_at_k79g2000hse.googlegroups.com...
> GROUP BY works on a single relation. The input relation's attributes
> are partitioned into one of three categories:
>
> 1) those we ignore
> 2) those we group by
> 3) those we apply the function to
>
> The result relation will have attributes from 2) above, and in
> addition:
>
> 4) those created as a result of the applied function.
>
> The functions mentioned in 4) may only use as arguments the attributes
> listed in 3).
>
> So for example given R(a, b, c):
>
> select b, sum(c) as d from R group by b
What if 1) above is empty?
select b from R group by a, b, ,c
Well, if R is a relational table, the group by will be unnecessary, since there will be at most one row per group. But if R is a bag, then group by a, b, c will project the bag onto a relation.
This is kind of a dumb example, since now you can't use aggregates. Just trying to touch all the bases. Received on Sat May 19 2007 - 16:08:04 CEST