79648156

Date: 2025-06-02 04:08:50
Score: 1
Natty:
Report link

On the upper right, change the engine. My solution here worked for MySQL.

SELECT
  MAX(IF(occupation = 'Doctor', name, NULL)) AS Doctor,
  MAX(IF(occupation = 'Professor', name, NULL)) AS Professor,
  MAX(IF(occupation = 'Singer', name, NULL)) AS Singer,
  MAX(IF(occupation = 'Actor', name, NULL)) AS Actor
FROM (
  SELECT 
    name, occupation,
    ROW_NUMBER() OVER (PARTITION BY occupation ORDER BY name) AS rn
  FROM occupations
) AS t
GROUP BY rn
ORDER BY rn;
Reasons:
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Om Khalid