select (case when rownum % 2 = 1 then id else null end)||','||(case when rownum % 2 = 0 then id else null end) from (select * from tablename order by id);
select t01||','||t02 from ( select t01,lead(t01)over(order by 1) t02 from t ) where mod(t01,2)=1
SELECT wmsys.wm_concat(id) str FROM ( SELECT rownum id, round(rownum/2) id2 FROM user_objects WHERE rownum<=20) GROUP BY id2
drop table test; create table test(id number);begin for i in 1..20 loop insert into test values(i); end loop; commit; end; /select a.id || ',' || b.id as id from (select t.*, rownum as rid from (select id from (select t.*, rownum as rid from test t order by id) where mod(rid, 2) = 1) t) a, (select t.*, rownum as rid from (select id from (select t.*, rownum as rid from test t order by id) where mod(rid, 2) = 0) t) b where a.rid = b.rid;ID -------------1,2 3,4 5,6 7,8 9,10 11,12 13,14 15,16 17,18 19,20
select max(a)||','||max(b) new_col from( select case when mod(rownum,2)=1 then col end a, case when mod(rownum,2)=0 then col end b from tab1) group by trunc((rownum-1)/2) order by new_col
with t as ( select 1 pkid from dual union select 2 from dual union select 3 from dual union select 4 from dual union select 5 from dual union select 6 from dual union select 7 from dual) select wmsys.wm_concat(pkid) f1 from (SELECT pkid,ceil(rn/2) rn1 FROM (select pkid,rownum rn from t)) group by rn1
with t as ( select 1 pkid from dual union select 2 from dual union select 3 from dual union select 4 from dual union select 5 from dual union select 6 from dual union select 7 from dual) select wmsys.wm_concat(pkid) f1 from (select pkid,rownum rn from t) group by ceil(rn/2)
from (select * from tablename order by id);
from
(
select t01,lead(t01)over(order by 1) t02 from t
)
where mod(t01,2)=1
FROM (
SELECT rownum id, round(rownum/2) id2
FROM user_objects
WHERE rownum<=20)
GROUP BY id2
drop table test;
create table test(id number);begin
for i in 1..20
loop
insert into test values(i);
end loop;
commit;
end;
/select a.id || ',' || b.id as id
from (select t.*, rownum as rid from (select id from (select t.*, rownum as rid from test t order by id) where mod(rid, 2) = 1) t) a,
(select t.*, rownum as rid from (select id from (select t.*, rownum as rid from test t order by id) where mod(rid, 2) = 0) t) b
where a.rid = b.rid;ID
-------------1,2
3,4
5,6
7,8
9,10
11,12
13,14
15,16
17,18
19,20
select case when mod(rownum,2)=1 then col end a,
case when mod(rownum,2)=0 then col end b
from tab1)
group by trunc((rownum-1)/2)
order by new_col
select 1 pkid from dual union
select 2 from dual union
select 3 from dual union
select 4 from dual union
select 5 from dual union
select 6 from dual union
select 7 from dual)
select wmsys.wm_concat(pkid) f1
from (SELECT pkid,ceil(rn/2) rn1
FROM (select pkid,rownum rn from t))
group by rn1
select 1 pkid from dual union
select 2 from dual union
select 3 from dual union
select 4 from dual union
select 5 from dual union
select 6 from dual union
select 7 from dual)
select wmsys.wm_concat(pkid) f1
from (select pkid,rownum rn from t)
group by ceil(rn/2)