SQL min: fixed bugs introduced by last Adolfo's commit. Improved performances avoiding to have a temporary array in memory, but rather used the iterator