Subject Re: [firebird-support] Re: Trouble with BETWEEN operator
Author Anderson Farias
> My concern is that people will come to grief if they misapply grouping and
> aggregation. The example shown by Anderson Farias illustrates one such
> misunderstanding:

No, theres no misunderstanding here (well, not from *my* part as far as I
can see).

the select into EXISTS will return 1 or nothing and do EXACTLY what Ain
wants. Theres nothing even conceptual wrong with it.


> SELECT r0.UID FROM TAB_A r0
> WHERE EXISTS (SELECT 1 FROM TAB_B WHERE
> r0.UID = AID having COUNT(1) BETWEEN 1 AND 10)
>
> which is not valid,

Have you tryed at all? It is pretty valid! It works fine and it's not a FB
*bug* for sure!

One could have changed the select inside EXISTS to

SELECT COUNT(1), 1 FROM TAB_B WHERE r0.UID = AID
having COUNT(1) BETWEEN 1 AND 10

Constants on select expressions do not have to be "grouped by"


> it would always terminate and return true if at least one match were made
> and would
> not ever reach the point of returning either true or false if there were
> more than 10
> matches.

What's wrong with that? One use EXISTS with this in mind right?

> The engine *should* return an "expression evaluation not supported" on
> this
> predicate.

I don't think so (and neither FB does)


Regards,
Anderson Farias