Improving insertBestOptionFromHistory sql sentence