by Thomas Kellerer <FJIFALSDGVAF@[EMAIL PROTECTED]
>
Feb 6, 2008 at 12:07 AM
strawberry wrote on 05.02.2008 23:34:
> On Feb 3, 1:39 am, "S." <sianeag...@[EMAIL PROTECTED]
> wrote:
>> Thanks Thomas,
>>
>> That was exactly what i was after!
>>
>> S.
>
> 5 stars! For that! Too generous! ;-)
>
> I think there must be a solution that doesn't require a subquery but
> my brains a bit frazzled today. I think it could be something along
> these lines, but I'd have to extend the dataset to be sure:
>
> SELECT t1.*
> FROM orders t1
> LEFT JOIN orders t2
> ON t1.customer = t2.customer
> AND t1.orderdate < t2.orderdate
> AND t2.orderdate < '2007-12-20'
> WHERE t2.id IS NULL
> HAVING orderdate < '2007-12-20';
A subquery is not necessarily slower or less efficient than a join. But
that
depends on the DBMS and the indexes available for the involved tables.
Tomas