Complex multiple Selects in Custom Coded Reports
In the CRM/Report folder: grep -r -i "TEMPORARY" *

This gives you some existing reports that use temp tables which you can look at to get some ideas.


Form/Activity.php
Form/Contribute/Detail.php
etc...