Select the "older" cell

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,
 
T

Tom van Stiphout

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top