Fixed #23605 -- added relabeled_clone() method to sql.Query

The problem manifested itself in rare cases where at least double nested
subquery's filter condition might target non-existing alias.

Thanks to Trac alias ris for reporting the problem.
distinct -> a different