Subject Re: SV: [firebird-support] Problem with query after upgrade FB 2.1x to 2.5.1
Author Ron
Svein,

Thank you very much. I set KeyLinksAutoDefine to false and the query worked as written. Also found the workarounds fascinating and educational.

Thanks again.

Ron

--- In firebird-support@yahoogroups.com, Svein Erling Tysvær <svein.erling.tysvaer@...> wrote:
>
> >Tools: Delphi 2006, IB Objects 4.9.14
> >
> >Query:
> >SELECT (COUNT(*)+0.00)/2 as "LabelsCount"
> >FROM LABELS
> >
> >previously worked. Now I get an error:
> >
> >Invalid expression in the select list (not contained in either aggregate function or GROUP BY clause
> >
> >However when I run the query from the SQL editor in Firebird Maestro it works and gives the correct result.
> >
> >Any ideas on why this won't work from Delphi\IB Objects?
>
> I'm impressed that it worked - I've never thought it was possible to further manipulate an aggregate result within the expression itself!
>
> Given that your query is quite unusual, I guess it is likely to be an IBO issue (e.g. I know IBO often adds RDB$DB_KEY to the select if you have KeyLinksAutoDefine (or similar) set to true - change it to false and your error may disappear), and as such it is more appropriate to ask on the ibobjects list than here. However, I would expect the following (and probably more common) workarounds to work:
>
> a)
> WITH TMP(CountLabels) as
> (SELECT COUNT(*) FROM LABELS)
> SELECT (CountLabels+0.00)/2 as "LabelsCount"
> FROM TMP
>
> b)
> SELECT SUM(0.5) as "LabelsCount" FROM LABELS
>
> HTH,
> Set
>