Recently I was asked to take the Certified Payroll report that comes with Dynamics and add Olympic Project Cost data to it. 
The query that runs the report is below. 
Warning:
This script depends quite a bit on the customer's data, and needs to be modified before use. If you don't have SQL chops, don't do it.