A simplified query can be run to see the problem:
select *
from inv_investments inv_investments
LEFT OUTER JOIN prj_ev_history EVREC ON EVREC.OBJECT_ID = INV_INVESTMENTS.ID
AND EVREC.OBJECT_TYPE='PROJECT' AND EVREC.PERIOD_NUMBER=0
where inv_investments.id = 5111008
--5111008 should be replaced by your project's internal ID
A query to identify all duplicates:
SELECT OBJECT_ID, OBJECT_TYPE, PERIOD_NUMBER, count(1)
from PRJ_EV_HISTORY
group by OBJECT_ID, OBJECT_TYPE, PERIOD_NUMBER having count(1) > 1
In order to resolve the duplicated row:Run the Update Earned Value and Cost Totals job, selecting the affected project in the job Investment parameter, to clear extraneous record from the PRJ_EV_HISTORY table. Alternatively, Update Cost Totals can be run from the Actions menu from one of the duplicate instances of the project.