I can't make this query work with SUM function
Posted
by Mehper C. Palavuzlar
on Stack Overflow
See other posts from Stack Overflow
or by Mehper C. Palavuzlar
Published on 2010-04-21T08:37:14Z
Indexed on
2010/04/21
8:43 UTC
Read the original article
Hit count: 500
This query gives an error:
select ep,
case
when ob is null and b2b_ob is null then 'a'
when ob is not null or b2b_ob is not null then 'b'
else null
end as type,
sum(b2b_d + b2b_t - b2b_i) as sales
from table
where ...
group by ep, type
Error: ORA-00904: "TYPE": invalid identifier
When I run it with group by ep
, the error message becomes:
ORA-00979: not a GROUP BY expression
The whole query works OK if I remove the lines sum(b2b_d+b2b_t-b2b_i) as sales
and group by ...
, so the problem should be related to SUM and GROUP BY functions. How can I make this work? Thanks in advance for your help.
© Stack Overflow or respective owner