我有一批数 类似
1 a
2 b
3 c
4 d
5 e
6 f
7 g
8 h
9 i
10 j
请问 如何按3条分类group by
123 456 789 10
------解决方案--------------------
这效果么 ?
with t1 as
(
select 1 c1,'a' c2 from dual union all
select 2 c1,'b' c2 from dual union all
select 3 c1,'c' c2 from dual union all
select 4 c1,'d' c2 from dual union all
select 5 c1,'e' c2 from dual union all
select 6 c1,'f' c2 from dual union all
select 7 c1,'g' c2 from dual
)
select rn,replace(wm_concat(c2),',','') c2
from
(
select c2,
case mod(rownum,3) when 2 then (rownum+1)/3
when 1 then (rownum+2)/3
when 0 then rownum/3 end rn
from t1
)
group by rn
order by rn
c2 rn
--------------------------
1 1 abc
2 2 def
3 3 g
------解决方案--------------------
这样也可以、
with t as
(select 1 c1, 'a' c2
from dual
union all
select 2 c1, 'b' c2
from dual
union all
select 3 c1, 'c' c2
from dual
union all
select 4 c1, 'd' c2