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: Question on Query

Re: Question on Query

From: <fitzjarrell_at_cox.net>
Date: Mon, 26 Nov 2007 09:24:02 -0800 (PST)
Message-ID: <bf8799ce-3fc4-4d70-968b-ed1a74accf14@d61g2000hsa.googlegroups.com>


On Nov 26, 11:03 am, m..._at_mtekusa.com wrote:
> On Nov 26, 9:29 am, "fitzjarr..._at_cox.net" <fitzjarr..._at_cox.net> wrote:
>
>
>
>
>
> > On Nov 26, 8:55 am, m..._at_mtekusa.com wrote:
>
> > > Hello,
>
> > > I have the following query:
>
> > > SELECT p.product_id "PRODUCT ID", p.name "PRODUCT NAME", count(*)
> > > "ACTIVE"
> > > FROM customer.subscriptions s, customer.product p
> > > WHERE p.product_id = s.product_id AND exp_date > SYSDATE
> > > GROUP BY p.product_id, p.name
> > > ORDER BY p.product_id;
>
> > > This works fine. However, what I need to do is SUM certain product
> > > numbers together and not others. So, if I have the following data:
>
> > > PRODUCT ID
> > > 1
> > > 2
> > > 3
> > > 4
> > > 5
>
> > > I want to sum product ID's 1 + 3, and the others will not be summed.
> > > Can this be done in a query? Maybe with DECODE?
>
> > > Thanks everyone!
>
> > Your description is a bit 'sketchy' as to what, exactly, you want, as
> > I'm fairly certain that your 'example' isn't completely defined. Nor
> > do you supply any Oracle release information (all four numbers),
> > necessary to provide a proper answer. What criteria are you using to
> > decide which product_id values to combine into subtotals? There may
> > be a number of 'solutions' to your problem but with the sparse
> > information you've provided supplying a usable suggestion is
> > difficult, at best.
>
> > Provide the requested data (Oracle release to 4 numbers, a better
> > problem description) and possibly someone can provide some information
> > you can use.
>
> > David Fitzjarrell
>
> We are running Oracle 10g R2.
>
> In the query, the criteria is very simple, I'm just joining 2 tables
> based on Product ID. But, certain Product ID's I want to combine
> together with regards to the COUNT(*).
>
> Can this be done with a query???- Hide quoted text -
>
> - Show quoted text -

HOW do you decide these 'certain' product_id values? Are the product_name values the same, or similar? Computing the sum of these totals is fairly simple, it's the reporting of these sums which may be a bit involved, as you haven't specified how you want those aggragates displayed.

David Fitzjarrell Received on Mon Nov 26 2007 - 11:24:02 CST

Original text of this message

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