Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Question on Query
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??? Received on Mon Nov 26 2007 - 11:03:07 CST
![]() |
![]() |