Fix mistake in SQL query