SELECT | MAX(SAL),MIN(SAL) |
FROM | EMP |
The aggregate function aggregates the values of the columns specified in the argument and returns the result; if the WHERE condition is specified, it returns the aggregate result for the extracted records.
SQL provides the following functions. SUM and AVG cannot take non-numeric arguments.
SUM | Sum of arguments: if NULL, not included in the tally |
MAX | Find the maximum value of the argument. |
MIN | Find the minimum value of the argument. |
AVG | Find the average value of the arguments; if NULL, it is not included in the tally. |
COUNT | If it is NULL, it is not counted.Can be described as COUNT(*). |
Now for the Practice, I will give you two questions.
goodsNo | date | quantity |
NP200 | 20031010 | 3 |
FP233 | 20031010 | 2 |
NP200 | 20031011 | 1 |
FP233 | 20031011 | 2 |
A | SELECT AVG(quantity) FROM Delivery Record WHERE goodsNo ='NP200' |
B | SELECT COUNT(*) FROM Delivery Record |
C | SELECT MAX(quantity) FROM Delivery Record |
D | SELECT SUM(quantity) FROM Delivery Record WHERE date = '20031011' |
This completes Functions (SUM, MAX, MIN, AVG, COUNT).