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