Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: "un-grouping" results
Using the link to asktom - decided to try to answer the question in
detail. Here is what I came up with:
SQL> create table exp (id varchar2(2), num number);
Table created.
SQL> insert into exp values ('A',2);
1 row created.
SQL> insert into exp values ('B',4);
1 row created.
SQL> insert into exp values ('C',5);
1 row created.
SQL> commit;
Commit complete.
SQL> select * from exp;
ID NUM
-- ----------
A 2 B 4 C 5
Now the query =>
1 select *
2 from ( select rownum r
3 from ( select 1 4 from dual group by cube (1,1,1,1,1,1))) a, 5 exp
1 A 2 2 A 2 1 B 4 2 B 4 3 B 4 4 B 4 1 C 5 2 C 5 3 C 5 4 C 5 5 C 5
11 rows selected.
Only caveat here is to make sure that the cube (1,1,1,1,1,1) will return more rows then you every would need (2 to the nth - or 2 to the sixth in this case). If you don't know that, then you would need to look into the pipeline function. I'm gonna check that out as well ;-) Received on Thu Feb 03 2005 - 20:37:00 CST
![]() |
![]() |