Query to delete registers. (1 Viewer)

pawson

New member
Local time
Today, 23:21
Joined
Mar 19, 2020
Messages
23
Hi good morning :D

I need to remove registers with an old version (products). But depends on each device. Here an example:

DEVICE_NAMEPRODUCT_NAME
A11234Microsoft Project Professional 2019
A11234Microsoft Project Professional 2010
A11234Microsoft Visual Studio Standard 2013
B56776Microsoft Visio Professional 2018
B56776Microsoft Visio Standard 2012
B56776Microsoft Visio Standard 2016

The results should be like:

DEVICE_NAME
PRODUCT_NAME
A11234Microsoft Project Professional 2019
A11234Microsoft Visual Studio Standard 2013
B56776Microsoft Visio Professional 2018
B56776Microsoft Visio Standard 2016

One product for each device will be removed because the versions are older. So that's what i want.

Kind regards
 

cheekybuddha

AWF VIP
Local time
Today, 22:21
Joined
Jul 21, 2014
Messages
2,274
Hi,

What is the table name?
What are all the field names in the table?
Which field is Primary Key?

Will this be a one-time job or something you will need to do regularly?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 05:21
Joined
May 7, 2009
Messages
19,230
you paste to Query design (SQL View) and replace Table with your tablename.
Code:
DELETE Table.PRODUCT_NAME, *
FROM [Table]
WHERE (((Table.PRODUCT_NAME) In (SELECT A.PRODUCT_NAME 
FROM [Table] AS A Inner Join [Table] AS B
ON Left(A.PRODUCT_NAME, InstrRev(A.PRODUCT_NAME, " ")) = Left(B.PRODUCT_NAME, InstrRev(B.PRODUCT_NAME, " "))
WHERE (((Right([A].[PRODUCT_NAME],4))<Right([B].[PRODUCT_NAME],4)))
)));
 

pawson

New member
Local time
Today, 23:21
Joined
Mar 19, 2020
Messages
23
Hi,

What is the table name?
What are all the field names in the table?
Which field is Primary Key?

Will this be a one-time job or something you will need to do regularly?
Hi,
Table name = Extraction
Field names = Product_Name & Device_Name
I don't have primary key.

I need to do it regularly but i know how to do it with macros. The thing is how to get the right query to delete the registers that are old version.
 

Users who are viewing this thread

Top Bottom