You may try the following:
With t as ( select client, transaction, min(date) as MinDate from file group
by etc)
Select b.*
From t join File b on t.client = b.client and t.Transaction = b.Transaction
and MinDate <= b.Date
Where b.Number > 0
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
-----Ursprüngliche Nachricht-----
Von: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] Im Auftrag von David FOXWELL
Gesendet: Friday, 11. December 2009 09:37
An: Midrange Systems Technical Discussion
Betreff: SQL puzzle
Can anyone help?
Here is My Transaction File:
Client Transaction date number
X Y 20090101 55
X Y 20090201 0
The field <number> is usually 0, but if not, the user <thinks> that this
will at the first transaction for a client, ie, minimum date value.
I want to prove or disprove this by extracting the 3rd line in the example,
if it exists :
Client Transaction date number
X Y 20090101 55
X Y 20090201 0
X Y 20090301 2
I want any line where number<>0 and date<> min date for client, transaction.
How can I do this?
I tried something like :
With t as ( select client, transaction, min(date) from file group by etc)
Then joining to the file where number >0 and date > min(date), but my
results aren't right.
Thanks.
As an Amazon Associate we earn from qualifying purchases.