Aggregate functions
SUM ()
 
COUNT function -- COUNT ()
 
MAX/MIN functions-MAX ()/MIN ()
 
Mean function-AVG ()
 
-----------------------------------------
 
Group by is a GROUP query. Generally, group by is used with Aggregate functions.
 
You use group by to group by the ITEM. ITEMNUM field. If the content of other fields is different, how can this problem be displayed?
 
A B
1 abc
1 bcd
1 asdfg
 
Select A, B from table group by
What are the results,
 
A B
Abc
1 bcd
Asdfg
 
How do the three entries on the right become one? So we need to use aggregate functions, such
 
Select A, count (B) quantity from table group by
The result is
A quantity
1 3
 
--------------------------------------
 
Store_Information table
 
Store_name Sales Date
 
Los Angeles $1500 Jan-05-1999
 
San Diego $250 Jan-07-1999
 
Los Angeles $300 Jan-08-1999
 
Boston $700 Jan-08-1999
 
Let's get
SELECT store_name, SUM (Sales) FROM Store_Information group by store_name
 
Result:
 
Store_name SUM (Sales)
 
Los Angeles $1800
 
San Diego $250
 
Boston $700
 
----------------------------------------
 
The principle of group by is that all columns after select do not use aggregate functions and must appear after group.