Subject Re: [firebird-support] Re: help with a select, i m out of ideas.
Author Arno Brinkman
Hi,

> SELECT FIRST 20 SUM(V.vnd_total) as TOTAL,
> (SELECT SUM(I.item_qtde) FROM items_venda I WHERE I.vnd_cod=V.vnd_cod) AS
> QTDE,
> C.cli_nome
> FROM VENDAS V
> JOIN clientes C ON (C.cli_cod=V.cli_cod)
> WHERE V.vnd_data BETWEEN '2006-1-01' AND '2006-1-31'
> GROUP BY C.cli_nome
> ORDER BY SUM(V.vnd_total) DESC
>
> And i got this error:
>
> Dynamic SQL Error SQL error code = -104 Invalid expression in the select
> list (not contained in either an aggregate function or the GROUP BY clause)
>
> Whats wrong?

V.vnd_cod isn't part of the GROUP BY clause.
Thus include V.vnd_cod in the GROUP BY clause or SUM the sub-select.

Regards,
Arno Brinkman
ABVisie

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
General database development support:
http://www.databasedevelopmentforum.com

Firebird open source database (based on IB-OE) with many SQL-99 features :
http://www.firebirdsql.org
http://www.firebirdsql.info
http://www.fingerbird.de/
http://www.comunidade-firebird.org/

Support list for Firebird and Interbase users :
firebird-support@yahoogroups.com

Nederlandse firebird nieuwsgroep :
news://newsgroups.firebirdsql.info