SELECT incl. CASE Statement and GROUP BY Clause
580108Apr 25 2008 — edited Apr 25 2008Hi,
I've a query including a case statement and group by. but i get an error at the bold printed attribute, although it is in the group by clause: ora-00979: not a group by expression
here is my query:
select TRIM(MLB308) as data_year,
SUBSTR(TRIM(MLB309), 2, 2) as data_month,
TRIM(MLB001) as entity_key,
TRIM(MLB004) as item_nr,
(case
when TRIM(MLB027) in (select distinct customerid from bc_cust_ic) then
TRIM(MLB027)
else
'no subsidary'
end) as customer_id,
sum(MLB014) as quantity
from zl01w130.mplb00@as400.world
where MLB071 in ('A')
and mlb308 in (2008, 2007)
and TRIM(MLB071) not in
('11', '11S', '14', '14S', '17', '17S', '27', '27S')
group by TRIM(MLB308),
SUBSTR(TRIM(MLB309), 2, 2),
TRIM(MLB001),
TRIM(MLB004),
TRIM(MLB027)
Any Advices from the experts?
Thx and regards,
Steffen