The usage of having clauses in SQL _php tutorial

Source: Internet
Author: User
One of the problems that users might want to address in the process of using the SQL language is to limit the output of the result of a sum or other aggregate function operation. For example, we may only want to see information about stores in the Store_information datasheet that have a total sales of more than $1500, and we need to use the HAVING clause. The syntax format is:
Select "Column_name1", SUM ("column_name2")
From "table_name"
GROUP by "column_name1"
Having (arithematic function condition)
(GROUP by clause optional)
Thus, we can use the following command to achieve the above query purposes:
SELECT store_name, SUM (sales)
From Store_information
GROUP by Store_name
Having SUM (sales) > 1500
The query results are displayed as:
Store_name SUM (Sales)
Los Angeles $1800
Small bet
When you set a query condition for a collection function in the SQL language, you use a HAVING clause instead of a WHERE clause. Typically, a HAVING clause is placed at the end of a SQL command true techarticle one of the problems that a having user might want to solve in the process of using the SQL language is to limit the output of the result of the operation of sum or other aggregate functions. For example, we may only want to see ...

  • 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: 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.