日期:2014-05-17 浏览次数:20802 次
CREATE TABLE T190 ( ID NUMBER(4), F1 VARCHAR2(20) ); INSERT INTO T190 VALUES(1, 'a'); INSERT INTO T190 VALUES(2, 'b'); INSERT INTO T190 VALUES(3, 'c'); INSERT INTO T190 VALUES(4, 'd');
------解决方案--------------------
估计楼主是想要分析函数的效果
lag() over 和lead() over()
------解决方案--------------------
with t as( select 1 id, 'a' name from dual union all select 2,'b' from dual union all select 3,'c' from dual union all select 4,'d' from dual )select id,name from t order by mod(id,4) ID NAME ---------- ---- 4 d 1 a 2 b 3 c
------解决方案--------------------
with t as( select 1 id, 'a' name from dual union all select 2,'b' from dual union all select 3,'c' from dual union all select 4,'d' from dual )select id,name from t order by mod(id+2,4) ID NAME ---------- ---- 2 b 3 c 4 d 1 a
------解决方案--------------------
with t as( select 1 id, 'a' name from dual union all select 2,'b' from dual union all select 3,'c' from dual union all select 4,'d' from dual )select mod(id+2,4)+1 id,name from t order by id ID NAME ---------- ---- 1 b 2 c 3 d 4 a