Subject RE: [firebird-support] SUM, group by
Author Alan McDonald
> Hello,
>
> I have following select statement, which reports me an error (error
> code -104, invalid expression in the select list):
>
> select Field1,Field2, Field3,
> SUM(Field4) as SField4,
> SUM(Field5) as SField5,
> SUM(Field6) as SField6
> from TABLE
> group by Field1
> order by Field1
>
>
> I want to get a sum of fields 4,5,6 for each of Field1.
>
> What am I missing here ?
>
>
>
> Regards,
> Primoz

try
> select Field1,Field2, Field3,
> SUM(Field4) as SField4,
> SUM(Field5) as SField5,
> SUM(Field6) as SField6
> from TABLE
> group by Field1, field2, field3

there's no need for order by - group by does it for you anyway
Alan