Oracle MAX function


/ Published in: SQL
Save to your folder(s)

A few examples of the MAX function.


Copy this code and paste it in your HTML
  1. SELECT * FROM student;
  2.  
  3. --Example 1
  4. SELECT MAX(fees_paid) AS MAX_TEST
  5. FROM student;
  6.  
  7. --Example 2
  8. SELECT MAX(first_name) AS MAX_TEST
  9. FROM student;
  10.  
  11. --Example 3
  12. SELECT MAX(enrolment_date) AS MAX_TEST
  13. FROM student;
  14.  
  15. --Example 4
  16. SELECT TO_CHAR(enrolment_date, 'MON') AS ENROLMENT_MONTH,
  17. MAX(fees_paid) AS MAX_FEES
  18. FROM student
  19. GROUP BY TO_CHAR(enrolment_date, 'MON');
  20.  
  21. --Example 5
  22. SELECT first_name, last_name, enrolment_date, MAX(fees_paid) OVER (PARTITION BY TO_CHAR(enrolment_date, 'MON')) AS MAX_TEST
  23. FROM student
  24. ORDER BY last_name, first_name

URL: http://www.databasestar.com/oracle-max/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.