No, it's not. The SUM(INV_PRICE)
will give you the total sales of an employee but the AVG(INV_PRICE)
will give you the average sale per employee, not the average (for all employees) of their total sales.
Try this of you want the average of total sales calculated for all employees - even those that have no sales at all:
SELECT EMP_ID, SUM(INV_PRICE) AS TOTAL_SALES
FROM INVOICE
GROUP BY EMP_ID
HAVING SUM(INV_PRICE) <=
( SELECT SUM(INV_PRICE) FROM INVOICE )
/ ( SELECT COUNT(*) FROM EMPLOYEE )
;
or this if you want the average of all employees that have sales:
SELECT EMP_ID, SUM(INV_PRICE) AS TOTAL_SALES
FROM INVOICE
GROUP BY EMP_ID
HAVING SUM(INV_PRICE) <=
( SELECT SUM(INV_PRICE) / COUNT(DISTINCT EMP_ID)
FROM INVOICE )
;
Skip that, Access has no COUNT(DISTINCT )
:
SELECT EMP_ID, SUM(INV_PRICE) AS TOTAL_SALES
FROM INVOICE
GROUP BY EMP_ID
HAVING SUM(INV_PRICE) <=
( SELECT AVG(TOTAL_SALES)
FROM
( SELECT SUM(INV_PRICE) AS TOTAL_SALES
FROM INVOICE
GROUP BY EMP_ID
) tmp
) ;