simple case solution


  • 2
    H
    SELECT (CASE 
        WHEN mod(id, 2) != 0 and records != id THEN id + 1
        WHEN mod(id, 2) != 0 and records = id THEN id
        ELSE id - 1
    END) AS id, student
    FROM seat, (select count(*) as records from seat) as seat_records
    ORDER BY id asc;
    
    

Log in to reply
 

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