DataBase - Select the "older" cell
Asked By kikeman
20-Nov-09 05:49 PM
Hi Guys,
I have a table "Orders" and I would like to erase the older entry from
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,
--
Eng. Enrique Lopez.
Database
(1)
DateDone
(1)
Stafford
(1)
Sheridan
(1)
Enrique
(1)
Guys
(1)
Undertaken
(1)
MIN
(1)
KenSheridan via AccessMonster.com replied to kikeman
This should do it:
DELETE *
FROM Orders AS O1
WHERE DateDone =
(SELECT MIN(DateDone)
FROM Orders AS O2
WHERE O2.Customer = O1.Customer);
Be sure to switch to datasheet view before executing the query to check that
it will be deleting the correct rows. And it goes without saying that before
these sort of set operations are undertaken the database should be backed up.
BTW database tables do not have 'cells'. That's a spreadsheet concept. Tables
have rows with values at column positions in each row.
Ken Sheridan
Stafford, England
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access/200911/1
Tom van Stiphout replied to kikeman
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
Run report in one database from another database DataBase Is there a way to run a report that was built in one database from another database? I have created a fairly complex report in one database that the users of another database need to view, however, there is other functionality in the database with the report that these users should not have access to. I don't want
Link to Database - Password DataBase HI, I have two database in two different folder. One (Database A) of the folder contains all the tables only. Other one is where I use the database (Database B) everyday and the database is linking the other database that has all the tables only. I set the Database B linking to Database A
importing data from one access database to another access database DataBase How do I import selected data and selected records from one access database to another access database. The field names are not currently always the same. I want to add people from one database into another database. Only some of the fields from the first database will be used in the second database. Access Tables DB Design Discussions Database (1) Access
Open one Database from another database DataBase I want to be able to open one database from a master database. I am not sure where to begin looking for help on this. I have tried looking under open but get the one context. Any ideas? Access Tables DB Design Discussions Database (1) Application.FollowHyperlink (1) RetVal (1) Girlshawn (1) Dale (1) Fye (1) Are you really interested in opening the other database, or just using some of the data from the 2nd database in the first application? If you want to do the latter, you can link tables