UPDATE measurement SET 
  calculationResultScope1 = null,
  calculationResultScope2 = null,
  calculationResultScope3 = 
  (
    (
      SELECT 
      (
        ((emissionfactors.emissionFactorManufacture / 1000) * [[measuredValue]]) * (1 - ([[secondaryMeasuredValue]] / 100)) + 
        ((emissionfactors.emissionFactorSecondary / 1000) * [[measuredValue]]) * ([[secondaryMeasuredValue]] / 100)
      )
      FROM emissionfactors 
      WHERE emissionfactors.productId = [[productId]]
      AND (
        YEAR(emissionfactors.validFrom) <= [[reportingYear]] 
        AND MONTH(emissionfactors.validFrom) <= [[reportingMonth]] 
      )
      ORDER BY emissionfactors.validFrom DESC
      LIMIT 1
    )
  ) * [[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]]