Subject Re: [firebird-support] What is wrong?
Author Alexandre Benson Smith
Francisco Antonio Vieira Souza wrote:

>begin
> FOR
> SELECT
> (SELECT MAX(v.quantfinal) FROM VALORTARIFAS t
> WHERE t.codtabela=:tarifa GROUP BY quantfinal) PESO_FINAL,
> v.valorfaixa
> FROM VALORTARIFAS v
> WHERE v.codtabela = :tarifa
> INTO :peso_final, :valor
> DO
> suspend;
>end
>
>Invalid token.
>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).
>
>
Francisco,

I don't understand you you expect with this query.

I suppose if you remove the group by part you will get what you want. I
assume you want tha max value of v.quantfinal for each :tarifa

SELECT
(SELECT MAX(v.quantfinal) FROM VALORTARIFAS t
WHERE t.codtabela=:tarifa) PESO_FINAL,
v.valorfaixa
FROM VALORTARIFAS v
WHERE v.codtabela = :tarifa
INTO :peso_final, :valor
DO
suspend;


see you !

--

Alexandre Benson Smith
Development
THOR Software e Comercial Ltda.
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br