Given a table of country and language spoken, fetch country and comma separated languages spoken list using a SQL query.
Given table example entries:
Country | Language |
India | Hindi |
India | Kannada |
India | Tamil |
China | Mandarine |
China | Cantonese |
Expected Result of SQL Query:
Country | Language_list |
India | Hindi, Kannada, Tamil |
China | Madarine, Cantonese |
constraint: no further querying is allowed from supporting objects of SQL query in question.
SELECT COUNTRY, LISTAGG(LANGUAGE, ', ') WITHIN GROUP (ORDER BY LANGUAGE) LANGUAGE_LIST FROM COUNTRY_LANGUAGE_TABLE GROUP BY COUNTRY;
No comments:
Post a Comment