UPDATE measurement SET 
  calculationResultScope3 = null,
  calculationResultScope2 = null,
  calculationResultScope1 = 
  (
    (
      SELECT 
        emissionfactors.emissionFactorUse 
      FROM emissionfactors 
      WHERE emissionfactors.productId = [[productId]]
      AND (
        YEAR(emissionfactors.validFrom) <= [[reportingYear]] 
        AND MONTH(emissionfactors.validFrom) <= [[reportingMonth]] 
      )
      ORDER BY emissionfactors.validFrom DESC
      LIMIT 1
    ) / 1000
  ) * [[measuredValue]],
  measurement.emissionFactorsId = (
    SELECT 
      emissionfactors.Id 
    FROM emissionfactors 
    WHERE emissionfactors.productId = [[productId]]
    AND (
      YEAR(emissionfactors.validFrom) <= [[reportingYear]] 
      AND MONTH(emissionfactors.validFrom) <= [[reportingMonth]] 
    ) 
    ORDER BY emissionfactors.validFrom DESC
    LIMIT 1
  )
  WHERE measurement.id = [[measurementId]]