Complex SQL statements

Source: Internet
Author: User

Select w.sta_list_id, W.sta_name,w.sta_title from (select b.sta_list_id, a.sta_name,a.sta_title,b.list_file_name from Area as D inner join Stadium_list as a in D.systemid =a.area_id inner join Stadium_list_field as B on A.systemid =b.sta_ list_id INNER JOIN Stadium_spe as C on B.sta_spe_id=c.systemid where d.area_name= ' Hongkou ') as W Group by all w.sta_list_id, W.sta_name,w.sta_title

Check again with the Found W table.

Group by group;

Order by sort

Group BY all grouped together in multiple fields

SELECT * from
A
where num >11
compute max (num), min (num), AVG (NUM)

Compute is to regenerate the results of the comput before using the aggregation function as a table.

The COMPUTE clause must be used with the ORDER BY clause
Compute...by compared with GROUP by,

Group by can only get statistical results for each set of data, not the data
The role of compute and compute by is not very large in real-world development, SQL Server supports compute and compute by, and access does not support
The purpose of the WHERE clause is to remove rows that do not conform to the where condition before grouping the results of the query, that is, filtering the data before grouping, where the cluster function cannot be included, and the Where condition is used to filter out specific rows.
The HAVING clause is used to filter groups that satisfy a condition, that is, to filter the data after grouping, often with clustering functions, to filter out specific groups using the having condition, or to group by using multiple grouping criteria.

Complex SQL statements

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.