Page 42 - Modular_V2.0_SQL_Flipbook
P. 42
+-----------+ +-----------+
| min(fees) | | max(fees)|
+-----------+ +-----------+
| 12000 | | 13000 |
+-----------+ +-----------+
The above recordset shows the use of MIN() and MAX() on the fees field of the table FEE. The
minimum and the maximum values will be extracted from the table values.
For example,
SELECT MAX(Marks) FROM STUDENT;
The output will be:
+------------+
| Max(Marks) |
+------------+
| 87 |
+------------+
The function MAX() will help to find the maximum value in the entire recordset.
Table-STUDENT Maximum Value in the column
Stu_id Stu_name Age Class Marks
101 Rahim 18 XII 87
102 Raja 19 XII 66
103 Riya 18 XII 55
Let us see some other examples of aggregate functions.
SELECT MIN(fee) FROM FEE;
SELECT SUM(quantity) FROM SHOP;
SELECT AVG(temp) FROM WEATHER;
SELECT COUNT(*) FROM EMPLOYEE;
Try these examples yourself.
Clickipedia
None of the functions consider NULL values into consideration for calculations. Those records are
simply ignored.
USING GROUP BY
This clause is helpful in managing groups and subgroups based on certain set of values. For example,
if you take Class XII students data into consideration, you can make 3 sub-groups based on their
subject choice like Science, Commerce and Liberal Arts. The GROUP BY clause will be very helpful in
making subject wise subgroups to understand the data better. For example,
Table-STUDENTS
Stu_id Stu_name Subject_group Class
101 Rahim Arts XII
102 Raja Commerce XII
40
Touchpad MODULAR (Ver. 2.0)

