Re: Tricky Sql Question

From: Ludovic DESSEMON <Pepiniere.rey_at_wanadoo.fr>
Date: 2 May 1998 07:07:20 GMT
Message-ID: <01bd7597$f8c34460$0b0000c0_at_ludovic>


You can use PL/SQL :

Create or replace procedure View_junk is Cursor cur_junk is
  select text, qty from junk_tab order by qty; v_qty Number;
v_text Varchar2(50);
BEGIN
for rec_junk in cur_junk loop

   if v_qty is not null and v_qty <> rec_junk.qty then

      dbms_output.put_line (v_text||'      '||to_char(v_qty));
      v_text := '';
      v_qty := rec_junk.qty;
   elsif v_qty is null then
      v_qty := rec_junk.qty;

   end if;
   v_text := v_text || rec_junk.text;
end loop;
dbms_output.put_line (v_text||' '||to_char(v_qty)); END; Ludovic DESSEMON

dmarsha3 <dmarsha3_at_csc.com> a écrit dans l'article <6ia5bu$323_at_explorer.csc.com>...
> Group :
>
> I have a table junk_tab(text,num,qty)
>
> Text num Qty
> ----------------
> A 1 5
> B 2 5
> C 3 5
> A 1 4
> B 2 4
> E 1 6
> F 2 6
>
>
> and I would like to have a result like
>
> ABC 5
> AB 4
> EF 6
>
> Could somebody give a tip,direction or solution for this problem.
>
> Thanks in advance
>
> rama
> rkolluru_at_csc.com
>
Received on Sat May 02 1998 - 09:07:20 CEST

Original text of this message