I'll write some nice clean CTEs and then have to refactor it to temp tables due to the lack of materialization.