Oracle MIN Function


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

A few examples of the MIN function


Copy this code and paste it in your HTML
  1. /*
  2. MIN
  3. */
  4.  
  5. SELECT * FROM student;
  6.  
  7. --Example 1
  8. SELECT MIN(fees_paid) AS MIN_TEST
  9. FROM student;
  10.  
  11. --Example 2
  12. SELECT MIN(last_name) AS MIN_TEST
  13. FROM student;
  14.  
  15. --Example 3
  16. SELECT MIN(enrolment_date) AS min_test
  17. FROM student;
  18.  
  19.  
  20. --Example 4
  21. SELECT TO_CHAR(enrolment_date, 'MON') AS ENROLMENT_MONTH,
  22. MIN(fees_paid) AS MIN_FEES
  23. FROM student
  24. GROUP BY TO_CHAR(enrolment_date, 'MON');
  25.  
  26.  
  27. --Example 5
  28. SELECT TO_CHAR(enrolment_date, 'MON') AS ENROLMENT_MONTH,
  29. MIN(fees_paid) AS MIN_FEES
  30. FROM student
  31. GROUP BY TO_CHAR(enrolment_date, 'MON')
  32. HAVING MIN(fees_paid) > 50;
  33.  
  34.  
  35. --Example 6
  36. SELECT first_name,
  37. last_name,
  38. enrolment_date,
  39. MIN(fees_paid) OVER (PARTITION BY TO_CHAR(enrolment_date, 'MON')) AS MIN_TEST
  40. FROM student
  41. ORDER BY last_name, first_name;

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.