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: "un-grouping" results

Re: "un-grouping" results

From: Mark C. Stock <mcstockX_at_Xenquery>
Date: Thu, 3 Feb 2005 16:52:22 -0500
Message-ID: <26idnasn6PuFAJ_fRVn-sg@comcast.com>

<sdbillsfan_at_gmail.com> wrote in message news:1107464904.799451.218110_at_o13g2000cwo.googlegroups.com...
> All-
> I'm looking for a way to pretty much do the opposite of a group
> by, count statement. Assuming I have a table with the following data:
>
> ID Quantity
> -- --------
> 1 4
> 2 3
>
> How would I use a select statement to return the following result set?:
>
> ID
> --
> 1
> 1
> 1
> 1
> 2
> 2
> 2
>
> Where I return a separate row for each id up to the quantity value for
> that row. I have a solution in place using a temp table and cursor but
> I figure there must be a better way.
>
> Thanks in advance.
>

look into pipelined functions, where you can right a PL/SQL function that gets accessed as if it were a table

10g's MODEL statement may also help, but it takes a bit of effort to sort out how it actually works

++ mcs Received on Thu Feb 03 2005 - 15:52:22 CST

Original text of this message

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