Subject | Re: [ib-support] Re: Newbie question IB about select |
---|---|
Author | Martijn Tonies |
Post date | 2002-08-29T14:44:08Z |
Hi Woody,
GROUP BY is an aggregate, just like SUM, MAX etc...
So by specifying MaterialType and MaterialSize1 & 2 in the GROUP BY
clause, you're using an aggregate on all columns - so this should work...
With regards,
Martijn Tonies
InterBase Workbench - the developer tool for InterBase and Firebird
http://www.interbaseworkbench.com
Upscene Productions
http://www.upscene.com
"This is an object-oriented system.
If we change anything, the users object."
> > > Select MaterialType, MaterialSize1, MaterialSize2, sum(MaterialWgt),columns?
> > > sum(MaterialWgt * MaterialCost) from Materials
> > > Group by MaterialType, MaterialSize1, MaterialSize2
> > >
> > > In what way would you change the query not to use non-aggregate
> > > Woody (TMW)...
> >
> > What are you getting at? All of your resulting columns are aggregated
>columns,
> Is not the definition of an aggregate column one whose value is computed?
> 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
> right?As soon as you use 1 aggregate, you need to use aggregates on all others.
GROUP BY is an aggregate, just like SUM, MAX etc...
So by specifying MaterialType and MaterialSize1 & 2 in the GROUP BY
clause, you're using an aggregate on all columns - so this should work...
>Where and whenever I can ... :)
> >
> > It's not me who made the SQL rules, you know :)
> >
>
> Sure, blame someone else... <VBG>
With regards,
Martijn Tonies
InterBase Workbench - the developer tool for InterBase and Firebird
http://www.interbaseworkbench.com
Upscene Productions
http://www.upscene.com
"This is an object-oriented system.
If we change anything, the users object."