/ Published in: SQL
A few examples of the AVG function.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
--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');
URL: http://www.databasestar.com/oracle-avg/