Subject Re: [firebird-support] "First N" ignored within subselect???
Author Alexandre Benson Smith
Joe wrote:
> I just ran into something bizarre.
>
> The following query:
>
> select first 10 custkey from customer where ....
>
> returns 10 rows, as I'd expect. However, if I put that in a subselect, like:
>
> select custkey from customer where custkey in
> (select first 10 custkey from customer where ....)
>
> This one returns 48 rows. Custkey is the primary key on the Customer table, so there can't be more than one customer with the same custkey.
>
> So, it appears that when when the "first n" is within a subselect, it is ignored, as far as I can tell.
>

In fact it's not ignored, but the sub-query is execute for every record
in the outer table, so it returns 10 records for every record in the
outer table.

> Is this a bug in Firebird? Or is there some legitimate reason that it was designed that way?
>

I don't know if it's a bug or if it's "work as designed", you know a
documented bug becomes a feature. :)

> I am running Firebird 1.0 if that affects the answer.
>
> -Joe
>

see you !

--
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br