Normal group by will show the first result. To get the last result for group by, use max()
https://paulund.co.uk/get-last-record-in-each-mysql-group
select max(id) from company_relocation_histories group by company_id