MySQL Study notes Day eighth

Source: Internet
Author: User

Where,group by,having Re-explanation

Where to use:
Where is used with in with, in (value 1, value 2, ...) ) indicates the result at value 1, value 2,。。。 Any one of them.

  
Aggregate functions and the use of GROUP by:
Aggregation function: In a select sentence with an aggregate function, it is meaningless to have other column names, which can be said to be wrong. Because the aggregation function asks
A whole, and the appearing of the stated is single.

(as you can see from here, KD876 is actually the name of Goods_id=1)
Gruop by and aggregation function, in order to show its power, the most important aggregation function has sum,avg,count,max,min,
They are often used with GROUP by: Select col_name, aggregate function from Tb_name GROUP by Col_name;
The aggregation function appears in this case to be useful, because the function here is to indicate the grouping.

Having usage: Where only works on the table structure, but having can work on the query results (the Select query still can be considered a table).
So where is called a query, having a filter.

  

MySQL Study notes Day eighth

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.