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 ."