so I have two tables, one of them is RAWtable, and the other is BASIC, I should get the last group identifier if there are several records (comparison of the same name, code). For example, I have this on a RAWtable:
id groupid name code 1 G09161405 Name1 Code1 2 G09161406 Name1 Code1
two records should be considered as one and should only return this value:
id groupid name code 2 G09161406 Name1 Code1
This row is the only row to be inserted into the main table. If you return the last group identifier (groupid is a combination of date and time)
I tried this but did not work:
SELECT MAST.ID, MAST.code, MAST.name FROM RAWtable AS MAST INNER JOIN (SELECT code, name, grouid,id FROM RAWtable AS DUPT GROUP BY code, name, groupid,id HAVING COUNT(*) >= 2) DUPT ON DUPT.code =MAST.code and DUPT.name =MAST.name where dupt.groupid >mast.groupid
How can i do this? Thank you very much.
source share