SQL having clause discovery

Source: Internet
Author: User

The tutorials on SQL having clauses are in the following format:

 
1 SelectColumn_name, aggregate_function (column_name)
2 FromTable_name
3 WhereColumn_name operator Value
4 Group ByColumn_name
5 HavingAggregate_function (column_name) operator Value

This column is above w3school, link: http://www.w3school.com.cn/ SQL/SQL _having.asp

The aggregate function after having must be an aggregate function after select.

 

However, in SQL Server 2008, I do the following:

1 SelectColumn_name
2 FromTable_name
3 WhereColumn_name operator Value
4 Group ByColumn_name
5 HavingAggregate_function (column_name) operator Value

This means that no aggregate function is used after select, but having is used.

No error is reported, and it seems that the correct results can be returned. I wonder if you have encountered a similar situation?

My mailbox tobethe2th@gmail.com welcome to discuss.

// Configure //--------------------------------------------------------------------------------------------

"Answers on sunny days" on csdn ":

"Not necessarily.
A prerequisite for having is that a group by clause can be used to set the range of aggregate function values, regardless of whether the group is queried or not ."

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.