Poiché i valori sono in int
stai facendo loro i nomi delle colonne, devi racchiudere i valori in un backtick
L'SQL sarà simile a:
max(case when user_id = 1 then score end) as `1`
La query completa sarà:
SET @sql = NULL;
SELECT
GROUP_CONCAT(DISTINCT
CONCAT(
'max(case when user_id = ''',
user_id,
''' then score end) AS `',
user_id, '`'
)
) INTO @sql
FROM measure2;
SET @sql = CONCAT('SELECT inspection_date, ', @sql, '
FROM measure2
GROUP BY inspection_date');
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
Vedi SQL Fiddle con demo