SQL Group Group Query

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.