解答如下:
----第一题
select max(case
when le = 1 then
lv
end) as c1,
max(case
when le = 2 then
lv
end) as c2,
max(case
when le = 0 then
lv
end) as c3
from (select lv, mod(lv, 3) as le ,row_number()over(partition by mod(lv, 3)order by lv ) as rn
from (select level as lv from dual connect by level <= 9))
group by rn
order by c1, c2, c3
---第二题
select max(case
when le = 1 then
lv
end) as c1,
max(case
when le = 2 then
lv
end) as c2,
max(case
when le = 3 then
lv
end) as c3
from (select lv, ceil(lv/ 4) as le ,row_number()over(partition by ceil(lv/4)order by lv ) as rn
from (select level as lv from dual connect by level <= 9))
group by rn
order by c1, c2, c3
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29507357/viewspace-1225030/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29507357/viewspace-1225030/