https://dba.stackexchange.com/questions/27775/loop-through-self-join-on-table-until-the-operand-column-is-null-completely