fixing error in sql