Students Report By Geography


  • 0

    Click here to see the full article post


  • 0
    P

    May I know if case when can be used here?
    I try to do:

    SELECT (CASE WHEN continent = 'America' then name else NULL END) AS America, (CASE WHEN continent = 'Asia' then name else NULL END) AS Asia, (CASE WHEN continent = 'Europe' then name else NULL END) AS Europe FROM student
    

    But I don't know how to remove the null values


  • 0

    @pxj5333 I don't think you can use case...when.... Please check the editorial solution instead.


  • 0
    V

    SELECT a.america, b.asia, c.europe
    FROM (SELECT ROWNUM rid, name AS America
    FROM student
    WHERE continent = 'America') A,
    (SELECT ROWNUM rid, name AS Asia
    FROM student
    WHERE continent = 'Asia') B,
    (SELECT ROWNUM rid, name AS Europe
    FROM student
    WHERE continent = 'Europe') C
    WHERE a.rid = b.rid(+) AND b.rid = c.rid(+);


  • 0
    G

    well, and what to do if we have not continents, but countries or cities? Wall of constants doesn't look like a solution


  • 0
    N

    @vineeshbnair unknown column ROWNUM error


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.