
Signature
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share
> Using Access and ASP (going to migrate to something more robust when
> this is cleaned up):
[quoted text clipped - 21 lines]
>
> Any help or ideas greatly appreciated. TIA.
Well, this query will return the last entry date for each card:
SELECT cardnumber, max(Added) LastEntryDate
FROM cards
GROUP BY cardnumber
While you could do a series of subqueries, for readability and
maintainability, I would suggest creating a saved query called
LatestEntryDatePerCard using that sql and use it in this query that
retrieves the ID of the last entry for each card (again, creating a saved
query - call it LatestCardIDs):
Select c.ID
From cards c join LatestEntryDatePerCard q
ON c.cardnumber =q.cardnumber and c.Added = q.LastEntryDate
Now this query should delete the earlier entries:
delete c.* from
cards c left join LatestCardIDs q
on c.ID = q.ID
WHERE q.ID Is Null
Probably more efficient would be to do this:
Select c.* into UniqueCards from
cards c join LatestCardIDs q
on c.ID = q.ID
Delete * From cards
Create the unique index on cards, and then:
insert into cards
select * from UniqueCards

Signature
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Adrienne Boswell - 15 Jun 2007 15:36 GMT
>> Using Access and ASP (going to migrate to something more robust when
>> this is cleaned up):
[quoted text clipped - 57 lines]
> insert into cards
> select * from UniqueCards
Thanks, Bob - you're always my hero! And Happy Father's Day!

Signature
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share
Adrienne Boswell - 17 Jun 2007 02:40 GMT
> Create the unique index on cards, and then:
>
> insert into cards
> select * from UniqueCards
That's what I ended up doing in the end. Believe me, I had the client here
while I was doing this, and he thought of at least four other more
complicated ways of doing it.

Signature
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share