Subject Re: [firebird-support] Re: Selecting invoices between specific dates?
Author Robin Davis
Hi,
>> I'm obviously missing something here.
>>
>> We have a table of invoices and we want to send Christmas cards to any
>> NEW clients in 2006. I am trying to select by invoicedate, which is
>> straight forward, but how in hell do I select people from that list who
>> we have billed in 2006 but NOT in previous years?
>>
>> Sorry, my brain has gone to mush!
>>
>>
> Could you try something like:
>
> select distinct name from invoices a
> where invoicedate >= '2006.01.01'
> and not exists (select 1 from invoices b
> where invoicedate < '2006.01.01'
> and b.name=a.name )
>
That's great, it works like a charm. Thanks to you both!

Rob