#考虑最大值
select
case when (id%2) = 1 and id < num then id+1
when (id%2) = 0 and id < num then id-1
else id end
as id,student
from Seat,(select max(id) as num from Seat) a
order by id
#不考虑最大值
select rank() over(order by change_id) as id,student
from
(select
case when (id%2)=1 then id+1
when (id%2)=0 then id-1
end as change_id,student
from Seat) t
注:本报产生的临时表