Returning the Maximum Value with MAX() : MAX « Aggregate Functions « SQL / MySQL






Returning the Maximum Value with MAX()

       
mysql>
mysql>
mysql> CREATE TABLE sales_rep(
    ->   employee_number INT,
    ->   surname VARCHAR(40),
    ->   first_name VARCHAR(30),
    ->   commission TINYINT
    -> );
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql>
mysql> INSERT INTO sales_rep values(4,'Rive','Mongane',10);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO sales_rep values(5,'Smith','Mike',12);
Query OK, 1 row affected (0.00 sec)

mysql>
mysql> SELECT MAX(commission) from sales_rep;
+-----------------+
| MAX(commission) |
+-----------------+
|              12 |
+-----------------+
1 row in set (0.00 sec)

mysql>
mysql> drop table sales_rep;
Query OK, 0 rows affected (0.00 sec)

mysql>

   
    
    
    
    
    
    
  








Related examples in the same category

1.Calculate the maximum value by using the MAX() function: MAX()
2.Get the maximum price and minimum price
3.Summarizing with MIN( ) and MAX( )
4.What are the first and last state names, lexically speaking?
5.Use the CONCAT( ) expression with MAX( ) to find the value with the largest population part:
6.Finding Values Associated with Minimum and Maximum Values
7.Determine the population range:
8.To obtain the state name associated with the maximum population
9.Finds the size of the largest message sent between each pair of sender and recipient values listed