mysql dynamic pivot

Solutions on MaxInterview for mysql dynamic pivot by the best coders in the world

showing results for - "mysql dynamic pivot"
Kennedy
19 Sep 2019
1SET @sql = NULL;
2SELECT
3  GROUP_CONCAT(DISTINCT
4    CONCAT(
5      'max(case when field_key = ''',
6      field_key,
7      ''' then field_value end) ',
8      field_key
9    )
10  ) INTO @sql 
11FROM
12  Meeting;
13SET @sql = CONCAT('SELECT Meeting_id, ', @sql, ' 
14                  FROM Meeting 
15                   GROUP BY Meeting_id');
16
17PREPARE stmt FROM @sql;
18EXECUTE stmt;
19DEALLOCATE PREPARE stmt;
20
21
similar questions
queries leading to this page
mysql dynamic pivot