Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Tricky Sql Question

Re: Tricky Sql Question

From: Saad Ahmad <saad.ahmad_at_mchugh.com>
Date: 1 May 1998 14:09:27 GMT
Message-ID: <01bd750a$bd5307e0$2207030a@sahmad-pc.mfa.com>


Assuming that you want to get all "Text" grouped by "Qty"

create or replace function get_txt_for_qty ( i_qty in junk_tab.qty%type ) return junk_tab.text%type is
cursor c1 is
select text
from junk_tab
where qty = i_qty
;
v_return varchar2(2000) := '';
begin
for v_rec in c1
loop

   v_return := v_return || v_rec.text;
end loop
return v_return;
end

select get_txt_for_qty ( c.qty ), c.qty from ( select qty

         from junk_tab
         group by qty
        ) c

;

dmarsha3 <dmarsha3_at_csc.com> wrote in article <6ia5qh$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 Fri May 01 1998 - 09:09:27 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US