Max - Min : MAX « Aggregate Functions « Oracle PL / SQL






Max - Min

   
create table emp(
         no          integer         primary key
        ,name        varchar2(20)    not null
        ,salary      number(10)
);

insert into emp(no, name, salary)
        values (1,'Nancy',30000);

insert into emp(no, name, salary)
        values (2,'Tom',  40000);

insert into emp(no, name, salary)
        values (3,'Jack', 30000);

insert into emp(no, name, salary)
        values (4,'Jason',10000);


select max(salary) - min(salary) from emp;

MAX(SALARY)-MIN(SALARY)
-----------------------
                  30000
1 row selected.

drop table emp;

   
    
  








Related examples in the same category

1.MAX: return the highest values in a column, ignore NULLs
2.Syntax: MAX ([DISTINCT]|[ALL] )
3.Use MAX with dates, it gives you the most recent dates
4.MAX with character data, retrieves the highest value alphabetically (that is, closest 'z').
5.Max with null value
6.Display the order number and total order price of the order(s) with the maximum total order price
7.max(total_price) - min(total_price)
8.Who have the max value
9.All rows with the max value