Select the "older" cell

  • Thread starter Thread starter kikeman
  • Start date Start date
K

kikeman

Hi Guys,

I have a table "Orders" and I would like to erase the older entry from
"Orders" for certain Customer. This table would have of course many Orders
for one Customer:

Customer - Order - DateDone
John - 1234 - 08.20.2009.6pm
John - 4567 - 10.20.2009.5pm
John - 8910 - 11.20.2009.7pm

What would be the DELETE/SELECT command that I would use to select the
oldest entry and erase it where the user would be John?
(in this case would be "John - 1234 - 08.20.2009.6pm")

I am using C#. But any suggestion in the command would help me.

Thanks,
 
On Fri, 20 Nov 2009 14:49:01 -0800, kikeman <[email protected]>
wrote:

Why do you want to delete orders? That seems like a really bad idea.

Assuming OrderNumber is unique, you could write:
(note: untested air code)
delete * from Orders where OrderNumber in (
select Min(OrderNumber from Orders group by Customer)
)

-Tom.
Microsoft Access MVP
 
Back
Top