Subject Re: subquery field in where phrase
Author tailuo2002
--- In firebird-support@yahoogroups.com, "unordained"
<unordained_00@...> wrote:
>
> >> select a.*, (select count(*) from a1 where a1.b_id = b.id) as F1
from tb a where (select count
> (*) from a1 where a1.b_id = b.id) = 100; [Alan]
>
> or if you're using FB2, something like:
>
> select z.* from
> (select a.*, (select count(*) from a1 where a1.b_id = b.id) as F1
from tb a) z
> where z.F1 = 100;
>
> or if you're using FB2.1, you could also try:
>
> with z (select a.*, (select count(*) from a1 where a1.b_id = b.id)
as F1 from tb a)
> select z.* from z where z.F1 = 100;
>
> As far as I know, there's no performance difference between any of
these options? (incl. Alan's?)
>
> - Philip
>

Thank you very much, that's great. I didn't know about table alias
before.