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.
an overview of what these queries are trying to calculate would definitely be helpful in case someone needs to debug regressions related to them in the future.