A solution without using union and order by


  • 5
    M

    A solution without using union and order by。

    select id,
    case 
        when id%2 = 0 then (select student from seat where id = (i.id-1) )  
        when id%2 != 0 and id<(select count(student) from seat) then (select student from seat where id = (i.id+1) )  
        else student
    end as student
    from seat i 
    

Log in to reply
 

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