This query is a data source for a report to calculate overtime pay on bonuses. I don't really understand the accounting, but the general idea is that if you pay a bonus and the employee has overtime in that period, the bonus needs to be increased because of the overtime.
This script handles that and produces the extra amount for the overtime bonus.
It may very well be company specific (it may only work for the company that I wrote it for) but I'm posting it in case it comes up.
If you use it, I'd be really interested in knowing that it worked or didn't. There is a comment area at the bottom of the article. Thanks!