Pivot table using math tricks

URL: http://en.wikibooks.org/wiki/Programming:MySQL/Pivot_table