I am using MariaDB 10.2.
The Customer Tag Table looks as below
I want to create a View/ Query which gives output as below
I was easily able to do so in Excel, but SQL query proved to be very difficult and erroneous.
I tried SQL
SELECT
GROUP_CONCAT( t.tagname ) INTO @PivotQuery
FROM
(SELECT
clienttag.customer, tagname
FROM
clienttag
GROUP BY
clienttag.customer, clienttag.office) t;
SET @PivotQuery = CONCAT('SELECT @PivotQuery' FROM clienttag GROUP BY customer');