I have the following weighted average equation I'm trying to put into the select clause
(( operating_hrsA * component countA ) + ( operating_hrsC * component countB ) + ( operating_hrsC * component countC )) / total compont_countABC
The select I'm trying to put it into is:
SELECT reporting_date_from,
reporting_date_to,
b_name,
oflag,
component_type,
SUM (component_count) AS component_count,
--AVG (average_operating_hours) AS average_operating_hours,
sum((average_operating_hours * component_count) / sum(component_count)) AS average_operating_hours
FROM DEVICE
where reporting_date_From = '01-JAN-2017' and b_name like '430%'
GROUP BY reporting_date_from,
reporting_date_to,
b_name,
oflag,
component_type;
error I'm getting is :
Error at line 1 ORA-00937: not a single-group group function
table schema : column | data type | Null ? reporting_date_From date N reporting_date_to date N b_name varchar2(100 byte) Y oflag varchar2(50 byte) Y component_type varchar2(50 byte) Y average_operating_hours number Y
data sample
any ideas what I'm doing wrong with this calculation?
thanks in advance