比如 我有个column
1
2
2
3
2
2
3
3
然后查出来 我要变成
1
2
3
2
3
也就是相邻的一样的数值就合并成一个
SQL> select * from tmp;
ID
----------
1
2
2
3
2
2
3
3
8 rows selected
SQL>
SQL> select id
2 from (select id,
3 rn,
4 row_number() over(partition by id order by rownum) - rn diff
5 from (select id, rownum rn from tmp))
6 group by id, diff
7 order by min(rn);
ID
----------
1
2
3
2
3
SQL>
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/13165828/viewspace-611411/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/13165828/viewspace-611411/