Looking at the example, it looks like it should run that subquery iteratively.
Looks like maybe this is a prime example for APPLY?
But an alias is being referenced (RT) which has not been specified so that query will not work.
Give us a query which will compile.