mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
Make the behavior of HAVING without GROUP BY conform to the SQL spec.
Formerly, if such a clause contained no aggregate functions we mistakenly treated it as equivalent to WHERE. Per spec it must cause the query to be treated as a grouped query of a single group, the same as appearance of aggregate functions would do. Also, the HAVING filter must execute after aggregate function computation even if it itself contains no aggregate functions.
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
$PostgreSQL: pgsql/doc/src/sgml/query.sgml,v 1.43 2005/01/22 22:56:36 momjian Exp $
|
||||
$PostgreSQL: pgsql/doc/src/sgml/query.sgml,v 1.44 2005/03/10 23:21:20 tgl Exp $
|
||||
-->
|
||||
|
||||
<chapter id="tutorial-sql">
|
||||
@ -783,8 +783,9 @@ SELECT city, max(temp_lo)
|
||||
will be inputs to the aggregates. On the other hand, the
|
||||
<literal>HAVING</literal> clause always contains aggregate functions.
|
||||
(Strictly speaking, you are allowed to write a <literal>HAVING</literal>
|
||||
clause that doesn't use aggregates, but it's wasteful. The same condition
|
||||
could be used more efficiently at the <literal>WHERE</literal> stage.)
|
||||
clause that doesn't use aggregates, but it's seldom useful. The same
|
||||
condition could be used more efficiently at the <literal>WHERE</literal>
|
||||
stage.)
|
||||
</para>
|
||||
|
||||
<para>
|
||||
|
Reference in New Issue
Block a user