Answer the question
In order to leave comments, you need to log in
How to copy grouped data to another table?
There is such a table: it is
necessary to copy the rows to another table, while it must be taken into account that the objectid field must be maximum for a certain person (unique personnelnumber field).
The second table should look like this:
Answer the question
In order to leave comments, you need to log in
INSERT INTO …
SELECT …
INNER JOIN ( SELECT personnelnumber, MAX(objectid) … GROUP BY personnelnumber ) …
Every day is the same. more or less like this:
INSERT INTO newtablename
(SELECT id, objectid, lastname, firstname, middlename, position, status, personnelnumber, organization_id
FROM tablename AS t1
WHERE t1.objectid = (SELECT max( t2.objectid ) FROM tablename AS t2 WHERE t1.personnelnumber = t2.personnelnumber)
GROUP BY personnelnumber, id, objectid, lastname, firstname, middlename, position, status, organization_id)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question