Subject RE: [IBO] Error in IB_Query while using UDF with aggregate
Author Svein Erling Tysvær
I don't think this is an IBO-related question and ought to have been asked on firebird-support. However, I'll answer here: I doubt UDFs can be used to encapsulate aggregate functions like you are trying to do here (I've never tried, but your error message indicates that Firebird is complaining about it). With Firebird 2.5, I'd probably rather try something more indirect like either:

with MySumCTE(MySum) as
(select sum(field1) from table1)
select round(MySum, 2) from MySumCTE

or, alternatively (note, I've never done anything similar, and it only works if you're returning one value, but if it works, it is likely to also work on older Firebird versions that doesn't support CTE's):

select round((select sum(field1) from table1), 2) from rdb$database

HTH,
Set

-----Original Message-----
From: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com] On Behalf Of tvoldemaras
Sent: 14. desember 2010 14:47
To: IBObjects@yahoogroups.com
Subject: [IBO] Error in IB_Query while using UDF with aggregate

Hi Jason,

I'm executing following statement in IB_Query:
'select round(sum(field1),2) from table1'

and getting ISC error 335544569, SQL error code -104
'Invalid expression in the select list(not contained in either an aggregate function or the GROUP BY clause)'.

field1 type is double precision.

Firebird server 2.5, IBObjects 4.9.11, Delphi 7

What I'm doing wrong?

Thanks