From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | jwieck(at)debis(dot)com (Jan Wieck) |
Cc: | pgsql-hackers(at)postgreSQL(dot)org (PostgreSQL HACKERS) |
Subject: | Re: [HACKERS] WHERE vs HAVING |
Date: | 1999-05-12 18:06:59 |
Message-ID: | 25460.926532419@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
jwieck(at)debis(dot)com (Jan Wieck) writes:
> I wonder what makes the difference between WHERE and HAVING
> that causes HAVING to accept aggregates while WHERE doesn't.
Huh? It seems inherent in the definition to me: WHERE is a filter
applied to individual tuples before any aggregation stage can happen,
thus it makes no sense for it to include aggregate functions
(except in explicit subselects, which create a new context for the
aggregation to occur in). HAVING applies to groups of tuples after
aggregation, so aggregate functions can meaningfully be applied to
those groups.
> It would be extremely nice if it's possible to teach WHERE
> how to handle aggregates properly. Having to push them into
> subselects during rewrite if a views aggregate column appears
> in the WHERE clause is a total mess.
Explain to me what you think it should mean. It sounds to me like
you are trying to have the rewrite system change an incorrect query
into a valid one. Doesn't strike me as a good idea; does the user
know what he's going to get?
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Keith Parks | 1999-05-12 19:27:21 | Patch to pg_dump for NUMERIC. |
Previous Message | Tom Lane | 1999-05-12 17:53:27 | Re: [HACKERS] BUG? serials and primary keys (was Re: [INTERFACES] Bug in psql?) |