corrected sql