We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
SELECT
CONCAT(GROUP_CONCAT(IF(Occupation = 'Doctor', Name, NULL) ORDER BY Name SEPARATOR ',')) AS Doctor,
CONCAT(GROUP_CONCAT(IF(Occupation = 'Professor', Name, NULL) ORDER BY Name SEPARATOR ',')) AS Professor,
CONCAT(GROUP_CONCAT(IF(Occupation = 'Singer', Name, NULL) ORDER BY Name SEPARATOR ',')) AS Singer,
CONCAT(GROUP_CONCAT(IF(Occupation = 'Actor', Name, NULL) ORDER BY Name SEPARATOR ',')) AS Actor
FROM OCCUPATIONS; CAN SOMBODY CORRECT IT
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Occupations
You are viewing a single comment's thread. Return to all comments →
SELECT CONCAT(GROUP_CONCAT(IF(Occupation = 'Doctor', Name, NULL) ORDER BY Name SEPARATOR ',')) AS Doctor, CONCAT(GROUP_CONCAT(IF(Occupation = 'Professor', Name, NULL) ORDER BY Name SEPARATOR ',')) AS Professor, CONCAT(GROUP_CONCAT(IF(Occupation = 'Singer', Name, NULL) ORDER BY Name SEPARATOR ',')) AS Singer, CONCAT(GROUP_CONCAT(IF(Occupation = 'Actor', Name, NULL) ORDER BY Name SEPARATOR ',')) AS Actor FROM OCCUPATIONS; CAN SOMBODY CORRECT IT