Fix mistake in previous sql query