Subject Re: [firebird-support] Way to avoid many subselects
Author Alexandre Benson Smith
Leyne, Sean wrote:
> Alexandre,
>
>
>> select
>> *
>> from
>> Customers cus join
>> Invoices Inv on (inv.customer_id = cus.customer_id)
>> where
>> not exists (select 1 from Invoices where Invoices.Customer_ID =
>> cus.CustomerID and Invoices.Invoice_ID > inv.Invoice_ID)
>>
>
> While this will get only 1 invoice, depending on way that the Invoice ID
> is stored/indexed, I don't believe that it guarantees getting the first
> invoice.
>
>
> Sean
>

Yes, I know, but if you look on the original query, he uses the same way
to find the first using sub-selects, I just used the same logic with a
diferente query to avoid the sub-selects.

But your point is valid !

see you !

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