• I agree that the problem's going to be connected to your row_number() and the fact that the field used in the Order by section of the OVER clause i.e. ANNUAL_CONTRACT_PRICE and/or CONTRACT_START_DATE are not unique for a customer.

    If you can add the other elements of the primary key into the 2 Order By's, then you should be OK. (I think!)