The MIN function returns the minimum value of an expression.MIN() function is reverse of MAX() function.MIN() function can be used along with GROUP BY clause also.
SYNTAX:
SELECT MIN(expression ) FROM tables WHERE (condition);
The example given below explains the usage of MIN() function and usage of MIN along with GROUP BY clause.
SQL> create table MYTABLE (name varchar2(50),age number,department varchar2(20)); Table created SQL> insert into MYTABLE values ('AAA',12,'D1'); SQL> insert into MYTABLE values ('BBB',42,'D2'); SQL> insert into MYTABLE values ('CCC',22,'D2'); SQL> insert into MYTABLE values ('DDD',32,'D1'); 4 row inserted SQL> select min(age) from MYTABLE; MIN(AGE) 12 SQL> select min(age) from MYTABLE where age >20; MIN(AGE) 22
Usage of MIN() function with GROUP BY
SQL> select department ,min(age) from MYTABLE group by department; DEPARTMENT MIN(AGE) D1 12< D2 22
Related Articles,
- SQL MIN Function | MIN() function in SQL
- SQL COUNT() Function ,Usage of COUNT(*) and COUNT(1)
- SQL order by ,using ‘ORDER BY’ clause in SQL
- Oracle Max(Date)? | sql max date
- Oracle Trim Function | PL/SQL TRIM Function.
- Oracle Decode Function | Use PLSQL DECODE function to handle NULL and default values
- SQL: MAX Function | SQL Max examples
- SQL GROUP BY Statement | SQL GROUP BY Clause examples
- NVL | Oracle/PLSQL: NVL Function
Technorati Tags:
SQL MIN, MIN function, MIN() function, GROUP BY
Pingback: SQL: MAX Function | Oracle Max() examples | SQL and PLSQL