Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL Question - Ranges of Sequences
I think you best bet is a PL/SQL loop that selects the date ordered by description, numeric, and builds a PL/SQL array in memory in a very traditional way.
The array can be turned into a cursor in a variety of ways dependent on the version of Oracle (see my web site for some options).
If you have Oracle 8, the initial select/order by need not be too expensive using array fetches (also see my web site), but the processing to build the result set could use a lot of CPU.
--
Jonathan Lewis
Yet another Oracle-related web site: www.jlcomp.demon.co.uk
Eddie wrote in message <7ne3bt$73l$1_at_nnrp1.deja.com>...
>Hi everybody, I would like your help on this query.
>I have a table:
>Create table test_table (id number, description varchar2 (20));
>with the following rows:
>Insert into table test_table values (1,'D1');
>Insert into table test_table values (2,'D1');
>Insert into table test_table values (3,'D1');
>Insert into table test_table values (4,'D2');
>Insert into table test_table values (7,'D2');
>Insert into table test_table values (8,'D2');
>Insert into table test_table values (20,'D3');
>Insert into table test_table values (21,'D3');
>Insert into table test_table values (22,'D3');
>Insert into table test_table values (23,'D4');
>Insert into table test_table values (30,'D4');
>commit;
>
>I want the result to look like this:
>
>from to description count
>--------------------------------------
>1 3 D1 3
>4 4 D2 1
>7 8 D2 2
>20 22 D3 3
>23 23 D4 1
>30 30 D4 1
>
>I appreciate your help,
>Thank you
>
>--
>Eddie
>Application Developer
>
>
>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.
Received on Sun Jul 25 1999 - 03:47:44 CDT
![]() |
![]() |