Subject Fb 1.5.4 - CASE - EXISTS - GROUP BY
Author Svein Erling Tysvær
I tried to do something like (chopping off the non-relevant bits of my real query)

select case when exists(select * from t2 where t1.field1 = t2.field2) then 1 else 0 end, count(*)
from t1
group by 1

This failed at prepare time.

I can make the statement prepare and execute if I modify the last line to

group by 1, t1.field1

but then I get far too many records returned (of course).

Short of using DDL (like a view or stored procedure), does anyone know any way to make this possible in Firebird 1.5.4? If a similar statement failed with 2.0 (I haven't tried), I would just put the CASE statement in the FROM clause, and with 2.1 I would try the new WITH statement that Vlad recently gave an example of in the CTE 101 thread, but with Fb 1.5.4 I suspect it isn't possible.

Set


[Non-text portions of this message have been removed]