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")
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)
GROUP by Store_name
Having SUM (sales) > 1500
The query results are displayed as:
Store_name SUM (Sales)
Los Angeles $1800
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
http://www.bkjia.com/PHPjc/631065.html www.bkjia.com true http://www.bkjia.com/PHPjc/631065.html 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 ...