Self join

* base_table        student subject    grade
                    ------- ---------- -----
                    Fred    reading    A
                    Fred    writing    B
                    Fred    arithmetic C
                    Mary    reading    B
                    Mary    writing    B
                    Mary    arithmetic C

CREATE VIEW pivot_table AS
SELECT a.student AS student, b.grade AS reading, c.grade AS writing, d.grade AS arithmetic
FROM (SELECT DISTINCT(student) FROM base_table) a
INNER JOIN (SELECT student,grade FROM base_table WHERE subject='reading') b
     ON b.student=a.student
INNER JOIN (SELECT student,grade FROM base_table WHERE subject='writing') c
     ON c.student = a.student
INNER JOIN (SELECT student,grade FROM base_table WHERE subject='arithmetic') d 
     ON d.student = a.student;

* pivot_table       student reading writing arithmetic
                    ------- ------- ------- ----------
                    Fred    A       B       C
                    Mary    B       B       C

/* What if you add a new subject? */
/* Performance?                   */