I need to delete all records based CF and max date and maintain the newest....
for example CF=A007, delete all and maintain the only records with date 19/08/1974
naturally if CF have only a records maintain and not delete...
hope you understand me.
DELETE all records based the max date
-
- PlatinumLounger
- Posts: 4368
- Joined: 26 Apr 2010, 17:36
DELETE all records based the max date
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78604
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: DELETE all records based the max date
The table contains 4 date fields: DTIST, DCESS, DTAGG and AL.
Which field should we use?
Which field should we use?
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4368
- Joined: 26 Apr 2010, 17:36
-
- Administrator
- Posts: 78604
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: DELETE all records based the max date
SQL = "DELETE DCESS FROM HANS WHERE CF='A007' AND DCESS<(SELECT Max(DCESS) FROM HANS WHERE CF='A007')"
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4368
- Joined: 26 Apr 2010, 17:36
-
- Administrator
- Posts: 78604
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: DELETE all records based the max date
It deletes entire records where CF equals 'A007' and DCESS is less than the maximum value for DCESS where CF equals 'A007'.
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4368
- Joined: 26 Apr 2010, 17:36