Subject Re: [ib-support] Re: Newbie question IB about select
Author Helen Borrie
At 09:35 AM 29-08-02 -0500, you wrote:

> >
> > What are you getting at? All of your resulting columns are aggregated ...
>
>Is not the definition of an aggregate column one whose value is computed?

No, Woody. An aggregate column is literally one that aggregates (gathers
together) a group of rows. Perhaps you are thinking of an "aggregate
function" or "aggregate expression" like SUM() or AVG()...? It's generally
pointless to have an aggregate query without an aggregate expression in
there somewhere, of course.

>The above doesn't compute the material type or size, only the combined
>weight and cost. In IB (and FB I believe) the SQL rules state that to use
>Group By in an aggregate query, you must include all non-aggregate columns,
>right?

No, the opposite, really. All of the columns involved in the query must be
capable of aggregation under the rule declared in the GROUP BY clause or
aggregating function.

For example, using your example, if your query was
Select MaterialType,
MaterialSize1,
MaterialSize2,
sum(MaterialWgt),
sum(MaterialWgt * MaterialCost),
DateCreated
from Materials
Group by MaterialType, MaterialSize1, MaterialSize2

would cause an error because DateCreated isn't aggregable (try to say that
while munching a cracker!!) under the groups determined by the GROUP BY clause.

heLen