Aggregate functions
Sum function--sum ()
 
Count function--count ()
 
Max/min value function-max ()/min ()
 
Mean value function--avg ()
 
—————————————————————————————————————————
 
Group BY is a grouped query, and general group by is used in conjunction with aggregate functions, you can think about
 
You used group BY press ITEM. Itemnum This field is grouped, the other field content is different, become a one-to-many and change how to show it, such as the following
 
A B
1 ABC
1 BCD
1 ASDFG
 
Select A,b from table GROUP by A
What do you mean by finding out this way,
 
A B
Abc
1 BCD
Asdfg
 
The right 3 how to become one, so you need to use aggregate functions, such as
 
Select A,count (B) Quantity from table group by A
So the result is
A Quantity
1 3
 
——————————————————————————————————————
 
Store_information table
 
Store_name Sales Date
 
Los Angeles $1500 jan-05-1999
 
San Diego $ jan-07-1999
 
Los Angeles $300 jan-08-1999
 
Boston $700 jan-08-1999
 
We'll break into
SELECT Store_name, SUM (Sales) from Store_information GROUP by Store_name
 
Results:
 
Store_name SUM (Sales)
 
Los Angeles $1800
 
San Diego $
 
Boston $700
 
————————————————————————————————————————
 
Group by has a principle that all columns following the Select Do not have columns that use aggregate functions and must appear after group by.