BUG: aliases does not work ((

Started by Eugen Konkovalmost 18 years ago4 messagesbugs
Jump to latest
#1Eugen Konkov
Eugen.Konkov@aldec.com

SELECT
MIN(COALESCE(cmp_values(parent_td.value, parent_md.value, parent_cmp.value),0)) as chk_parent,
FROM some_table

having chk_parent > 0

ERROR: column "chk_parent" does not exist at character 2342

#2Peter Eisentraut
peter_e@gmx.net
In reply to: Eugen Konkov (#1)
Re: BUG: aliases does not work ((

Am Mittwoch, 7. Mai 2008 schrieb Eugen.Konkov@aldec.com:

SELECT
MIN(COALESCE(cmp_values(parent_td.value, parent_md.value,
parent_cmp.value),0)) as chk_parent, FROM some_table

having chk_parent > 0

ERROR: column "chk_parent" does not exist at character 2342

Aliases in the select list are not in scope in the having clause. Either
write out the expression again or use a subquery.

#3Eugen Konkov
Eugen.Konkov@aldec.com
In reply to: Eugen Konkov (#1)
Re: BUG: aliases does not work ((

Aliases in the select list are not in scope in the having clause.

it will be good if aliases will be in scope of 'having' clause.
Because of dublicating code is cause of bugs when people foget replace code
in second place while changing code in first one =(

----- Original Message -----
From: "Peter Eisentraut" <peter_e@gmx.net>
To: <pgsql-bugs@postgresql.org>
Cc: <Eugen.Konkov@aldec.com>
Sent: Wednesday, May 07, 2008 2:52 PM
Subject: Re: [BUGS] BUG: aliases does not work ((

Show quoted text

Am Mittwoch, 7. Mai 2008 schrieb Eugen.Konkov@aldec.com:

SELECT
MIN(COALESCE(cmp_values(parent_td.value, parent_md.value,
parent_cmp.value),0)) as chk_parent, FROM some_table

having chk_parent > 0

ERROR: column "chk_parent" does not exist at character 2342

Aliases in the select list are not in scope in the having clause. Either
write out the expression again or use a subquery.

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Eugen Konkov (#3)
Re: BUG: aliases does not work ((

<Eugen.Konkov@aldec.com> writes:

Aliases in the select list are not in scope in the having clause.

it will be good if aliases will be in scope of 'having' clause.

Feel free to try to convince the SQL standards committee ...

regards, tom lane