Oracle: SQL MIN Function | MIN() function in SQL

0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 Buffer 0 Email -- Filament.io 0 Flares ×
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,

Technorati Tags:
, , ,

0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 Buffer 0 Email -- Filament.io 0 Flares ×

1 thought on “Oracle: SQL MIN Function | MIN() function in SQL

  1. Pingback: SQL: MAX Function | Oracle Max() examples | SQL and PLSQL

Leave a Reply

Your email address will not be published. Required fields are marked *

Paged comment generated by AJAX Comment Page