Skip to content

618. Students Report By GeographyΒΆ

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
WITH
  StudentWithIdInContinent AS (
    SELECT
      *,
      ROW_NUMBER() OVER(PARTITION BY continent ORDER BY name) AS id
    FROM Student
  )
SELECT
  MAX(CASE WHEN continent = 'America' THEN name END) AS America,
  MAX(CASE WHEN continent = 'Asia' THEN name END) AS Asia,
  MAX(CASE WHEN continent = 'Europe' THEN name END) AS Europe,
  id
FROM StudentWithIdInContinent
GROUP BY id;
Buy Me A Coffee
Thanks for stopping by! If you find this site helpful, consider buying me some protein powder to keep me fueled! πŸ˜„