Revert changes on sql related to calculate the result for many nodes