Subject | Re: Aggregate function with CASE and GROUP BY clauses |
---|---|
Author | Svein Erling Tysvær |
Post date | 2005-09-13T10:53:11Z |
I tried running something very similar (using count rather than sum)
and had no problems whatsoever! Maybe you are using dialect 1 or
something?
HTH,
Set
and had no problems whatsoever! Maybe you are using dialect 1 or
something?
HTH,
Set
--- In firebird-support@yahoogroups.com, "Roberto Freitas" wrote:
> I tried the following query against WI-V1.5.2.4731 Firebird 1.5 :
>
> SELECT CASE WHEN (val < 0) then 'C' ELSE 'D' END as CD,
> SUM(clc_valor) AS TOT
> FROM Lanto
> WHERE (cod = '10010001')
> GROUP BY 1
>
> but it raises an exception class EIB_ISCError
> ISC ERROR CODE:335544569
> ISC ERROR MESSAGE:
> Dynamic SQL Error
> SQL error code = -104
> Cannot use an aggregate function in a GROUP BY clause
>
> I suppose I could use an aggregate function with CASE and GROUP BY
> clauses.
> Cant'I or there is something else wrong?