General numerical functions include sum, avg, ceil, floor, trunc, and round(n).
To calculate the total sales and average sales per order in each warehouse and region from the hist table, execute the following SQL statement:
SELECT h_w_id, h_d_id, sum(h_amount) sum_h_amount , avg(h_amount) avg_h_amount
FROM hist
GROUP BY h_w_id, h_d_id ;
Result:
+--------+--------+--------------+--------------+
| h_w_id | h_d_id | sum_h_amount | avg_h_amount |
+--------+--------+--------------+--------------+
| 1 | 1 | 120.00 | 10.000000 |
| 1 | 2 | 120.00 | 10.000000 |
| 1 | 3 | 120.00 | 10.000000 |
| 1 | 4 | 120.00 | 10.000000 |
| 1 | 5 | 120.00 | 10.000000 |
| 1 | 6 | 120.00 | 10.000000 |
| 1 | 7 | 120.00 | 10.000000 |
| 1 | 8 | 120.00 | 10.000000 |
| 1 | 9 | 120.00 | 10.000000 |
| 1 | 10 | 120.00 | 10.000000 |
| 2 | 1 | 120.00 | 10.000000 |
| 2 | 2 | 120.00 | 10.000000 |
| 2 | 3 | 120.00 | 10.000000 |
| 2 | 4 | 120.00 | 10.000000 |
| 2 | 5 | 120.00 | 10.000000 |
| 2 | 6 | 120.00 | 10.000000 |
| 2 | 7 | 120.00 | 10.000000 |
| 2 | 8 | 120.00 | 10.000000 |
| 2 | 9 | 120.00 | 10.000000 |
| 2 | 10 | 120.00 | 10.000000 |
+--------+--------+--------------+--------------+
20 rows in set (0.02 sec)