Funciona de la misma manera que FS_amount
, simplemente agregue las nuevas columnas a su código que genera las columnas dinámicas:
SELECT GROUP_CONCAT(DISTINCT CONCAT(
'MAX(IF(month = ''',
month,
''' and year(date) = ',
year(date),
', FS_amount, NULL)) AS `',
CONCAT('FA_',month),
'_',
year(date),
'`, ',
'MAX(IF(month = ''',
month,
''' and year(date) = ',
year(date),
', AS_amount, NULL)) AS `',
CONCAT('AS_',month),
'_',
year(date),
'`'
)
order by date
) INTO @sql
FROM tmp_results;
Debería echar un vistazo al código que crean las declaraciones (por ejemplo, agregando temporalmente un select @sql;
), aunque debería ser bastante sencillo agregar aún más columnas en caso de que las necesite.