corrected sql code