Use the below queries;
To find the number of duplicate users:
SELECT objectguid, COUNT(*) TotalCount FROM aduser GROUP BY objectguid HAVING COUNT(*) > 1;
SELECT userid, samaccname, objectguid, COUNT(*) TotalCount FROM aduser GROUP BY userid, samaccname, objectguid HAVING COUNT(*) > 1;
To update the local user to AD user please use the below query,
update aduser set userid="local userid" where samaccname='XXXX';