Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Case statement in Group by ?
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