📉 Oracle MIN() Function Guide

📉 Oracle MIN() Function Guide

This tutorial covers how to use the Oracle MIN() function to find the smallest value in a column. You’ll also see examples with GROUP BY, HAVING, and subqueries.


📌 What is Oracle MIN()?

The MIN() function returns the minimum value from a set of values in a column. It works on numeric, date, and string data types and ignores NULL values.

🧮 Syntax

MIN(expression)

Where expression is usually a column name.

📋 Example 1: MIN on Numeric Column

Find the lowest salary in the employees table:

SELECT MIN(salary) AS lowest_salary
FROM employees;

📋 Example 2: MIN with GROUP BY

Find the lowest salary in each department:

SELECT department_id, MIN(salary) AS lowest_salary
FROM employees
GROUP BY department_id;

📋 Example 3: MIN with HAVING

Return departments where the minimum salary is below 5,000:

SELECT department_id, MIN(salary) AS lowest_salary
FROM employees
GROUP BY department_id
HAVING MIN(salary) < 5000;

📋 Example 4: MIN in Subquery

Find employee(s) with the lowest salary:

SELECT first_name, last_name, salary
FROM employees
WHERE salary = (
  SELECT MIN(salary)
  FROM employees
);

📋 Example 5: MIN on Date Column

Find the earliest hire date:

SELECT MIN(hire_date) AS earliest_hire
FROM employees;

📋 Example 6: MIN on Strings

Find the employee with the first last name alphabetically (A → Z):

SELECT MIN(last_name) AS first_alphabetically
FROM employees;

✅ Summary

  • MIN() returns the smallest value from a set.
  • Works with numbers, dates, and strings.
  • Ignores NULL values.
  • Supports use with GROUP BY and HAVING.
  • Useful in subqueries to filter rows by minimum values.

Oracle's MIN() function is a straightforward way to find minimum values in your data.

Keywords:

  • Oracle aggregate functions tutorial
  • Oracle GROUP BY clause training
  • Oracle SUM() function guide
  • Oracle AVG() function tutorial
  • Oracle COUNT() function hands-on
  • Oracle aggregate functions example
  • Oracle SQL aggregate functions course
  • Oracle group functions training
  • Oracle real-time aggregate training
  • Oracle SQL tutorial for beginners
  • Oracle aggregate functions practice

Tags:

#Oracle #SQL #AggregateFunctions #OracleTutorial #SQLTraining #DatabaseLearning #OracleSQL #SQLHandsOn #DataAggregation #SQLForBeginners #OracleGroupBy #SUMFunction #AVGFunction #COUNTFunction

একটি মন্তব্য পোস্ট করুন