1. Using GROUP by for group queries
When using the group by keyword, the items that can be specified in the select list are limited, and only the following items are allowed in the SELECT statement:
The columns that are grouped
Returns a worthwhile expression for each grouping, such as an aggregate function with a column name as a parameter
The use of group by is to write a few examples here:
Cases:
Select CourseID, avg as course average score from scoreGroupby CourseID
Cases:
Select as as internal test, avg as internal Test average score from scoreGroup by Studentid,courseid
2. Grouping filtering using the HAVING clause
The WHERE clause can only filter data rows that do not have group statistics, and the filter for grouped conditions must use the HAVING clause
Cases:
Select as as internal test, avg as internal Test average score from scoreGroup by Studentid,courseid having avg (score) > -
In the SELECT statement, the Where, group BY, have clauses, and statistical functions are executed in the following order:
The WHERE clause removes data from the data source that does not conform to the search criteria; The GROUP BY clause collects data rows into individual groups, and the statistics function calculates the statistics for each group; the HAVING clause strips out the groups of data rows that do not conform to their group search criteria.
WinForm Framework Source Code-devexpress Development Framework
SQL Group Group Query