-------------------- Windows Phone 7 Mobile Phone development,. Net training, and hope to communicate with you! ----------------------
The book says that group by can divide a table into logical groups and calculate aggregate statistics for each group .. I didn't understand the meaning of this sentence at first, and I finally understood it with the help of everyone.
The literal meaning of group by is: grouping.
Assume that there is a t_person table.
The table has the following attributes: ID, name, age, and salary.
Then we need to retrieve the age groups (by age group) and the corresponding highest salary (the clustering function acts on each group ):
Select age as age, max (salary) as maximum salary from t_person group by age
For example:
ID name age salary
1 Steven 19 5362
2 WiFi 19 5620
3 Amy 21 5320
4 bin 23 5000
5 fin 22 5600
6 okn 23 6520
Output:
Maximum age wage
19 5620
21 5320
22 5600
23 6520
NOTE: If no query group is configured, the aggregate function applies to the entire query result! Only the maximum 6520
-------------------- Windows Phone 7 Mobile Phone development,. Net training, and hope to communicate with you! ---------------------- For details, please refer to: http://net.itheima.com/
-------------------- Windows Phone 7 Mobile Phone development,. Net training, and hope to communicate with you! ----------------------
The book says that group by can divide a table into logical groups and calculate aggregate statistics for each group .. I didn't understand the meaning of this sentence at first, and I finally understood it with the help of everyone.
The literal meaning of group by is: grouping.
Assume that there is a t_person table.
The table has the following attributes: ID, name, age, and salary.
Then we need to retrieve the age groups (by age group) and the corresponding highest salary (the clustering function acts on each group ):
Select age as age, max (salary) as maximum salary from t_person group by age
For example:
ID name age salary
1 Steven 19 5362
2 WiFi 19 5620
3 Amy 21 5320
4 bin 23 5000
5 fin 22 5600
6 okn 23 6520
Output:
Maximum age wage
19 5620
21 5320
22 5600
23 6520
NOTE: If no query group is configured, the aggregate function applies to the entire query result! Only the maximum 6520
-------------------- Windows Phone 7 Mobile Phone development,. Net training, and hope to communicate with you! ---------------------- For details, please refer to: http://net.itheima.com/