Return to Snippet

Revision: 71289
at February 10, 2017 06:38 by bbrumm


Initial Code
--AVG Function

SELECT * FROM student;

--Example 1
SELECT AVG(fees_paid) AS avg_fees_paid
FROM student;

--Example 2
SELECT TO_DATE(ROUND(AVG(TO_NUMBER(TO_CHAR(enrolment_date, 'J')))), 'J') AS avg_date
FROM student;


--Example 3
SELECT gender, AVG(fees_paid) AS avg_fees_paid
FROM student
GROUP BY gender;


--Example 4
SELECT gender, AVG(fees_paid) AS avg_fees_paid
FROM student
GROUP BY gender
HAVING AVG(fees_paid) > 200;


--Example 5
SELECT TO_CHAR(enrolment_date, 'MON') AS ENROLMENT_MONTH,
AVG(fees_paid) AS avg_fees_paid
FROM student
GROUP BY TO_CHAR(enrolment_date, 'MON');

Initial URL
http://www.databasestar.com/oracle-avg/

Initial Description
A few examples of the AVG function.

Initial Title
Oracle AVG Function

Initial Tags
sql, Oracle

Initial Language
SQL