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: 9 Feb 2005 15:29:38 -0800
Message-ID: <1107991778.016855.199520@f14g2000cwb.googlegroups.com>


Here is what I am trying:

Select
  MAX(c1),
  sum(qty),
  c2
from
  t1
where
  c1 = 'test'
  Having
(

     SUM(qty) > @TotalItemsParam
  )
AND
(

     c4 = @somevar and @condition = 'true' <-- wants me to have a group by, but I do not want
  )
group by
  case when @condition = 'true' then c4 else c2 end

The C4 in the having wants me to include the group by, which I do not want. Ideally I would want to include the AND statement and group by only if some condition is true. I hope that makes sense. Please suggest me. Received on Wed Feb 09 2005 - 17:29:38 CST

Original text of this message

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