You can do this with substring_index() . The following query uses yours as a subquery, and then applies this logic:
select Name, ISOCode_2, substring_index(currencies, ',', 1) as Currency1, (case when numc >= 2 then substring_index(substring_index(currencies, ',', 2), ',', -1) end) as Currency2, (case when numc >= 3 then substring_index(substring_index(currencies, ',', 3), ',', -1) end) as Currency3, (case when numc >= 4 then substring_index(substring_index(currencies, ',', 4), ',', -1) end) as Currency4, (case when numc >= 5 then substring_index(substring_index(currencies, ',', 5), ',', -1) end) as Currency5, (case when numc >= 6 then substring_index(substring_index(currencies, ',', 6), ',', -1) end) as Currency6, (case when numc >= 7 then substring_index(substring_index(currencies, ',', 7), ',', -1) end) as Currency7, (case when numc >= 8 then substring_index(substring_index(currencies, ',', 8), ',', -1) end) as Currency8 from (SELECT country.Name, country.ISOCode_2, group_concat(currency.name) AS currencies, count(*) as numc FROM country INNER JOIN countryCurrency ON country.country_id = countryCurrency.country_id INNER JOIN currency ON currency.currency_id = countryCurrency.currency_id GROUP BY country.name ) t
The expression substring_index(currencies, ',' 2) takes a list in currencies up to the second. For American Somoa, it will be 'US Dollar,Kwanza' . The next call with -1 as an argument takes the last element of the list, which will be 'Kwanza' , which is the second element of currencies .
Also note that SQL queries return a well-defined set of columns. A query cannot have a variable number of columns (unless you use dynamic SQL through the prepare statement).