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: Case statement in Group by ?

Re: Case statement in Group by ?

From: <sonukapoor_at_gmail.com>
Date: 10 Feb 2005 09:31:32 -0800
Message-ID: <1108056692.651116.125600@f14g2000cwb.googlegroups.com>


Here is a complete explaination of what I am trying:

I have a table which lets say looks like this:

ID - Type - Amount - Color - Store


1 - S - 10 - RED - CMS
2 - L - 20 - Blue - CMS
3 - X - 20 - Pink - CMS
4 - S - 30 - RED - LT1
5 - L - 40 - Blue - LT1
6 - X - 40 - Pink - LT1
7 - Q - 25 - Grey - LSW

Now lets say, I want to see the result like this:

Amount - Store



50 - CMS
110 - LT1
25 - LSW This would be grouped by Store.

Now lets say, I want to pass an variable for color, which would change that SQL so that I get this result:

Color - Amount



Red - 2
Blue - 2
Pink - 2
Grey - 1

I want to be able to get both results depending on the variable I pass. If I pass a color, then I would like to see the below result. If not then the above one. Received on Thu Feb 10 2005 - 11:31:32 CST

Original text of this message

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