[MONDRIAN-1226] Prettied up the SQL.