SUM() the commission : SUM « Aggregate Functions « SQL / MySQL






SUM() the commission

     
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>
mysql> SELECT SUM(commission) from sales_rep;
+-----------------+
| SUM(commission) |
+-----------------+
|              22 |
+-----------------+
1 row in set (0.00 sec)

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

   
    
    
    
    
  








Related examples in the same category

1.SUM() function returns the sum of the expression.
2.Sum by group
3.Some aggregate functions can still produce NULL as a result.
4.What is the total amount of mail traffic and the average size of each message?
5.What is the total population of the United States?
6.Summaries and NULL Values
7.To determine how many drivers were on the road and how many miles were driven each day
8.Finding Smallest or Largest Summary Values
9.The number of votes for each programming language is determined with SUM(IF(...))
10.To compute the runner's average speed at the end of each stage