But in any case, it turns out my query was correct, and it was just taking far too long. I worked around the issue by requiring that you select a start date for an on-screen report, and warning the user that doing a printable report without a start date could take an extremely long time.
Are TRANSFORM and PIVOT available in MySQL? I'm not familiar with them.