Re: [GENERAL] Understanding Aliases

2007-12-12 Thread Vyacheslav Kalinin
> SELECT-list output aliases name the *output* columns of the SELECT. > Those output columns are not available to the SELECT's computation > clauses Then it's unclear how could the first query work

Re: [GENERAL] Understanding Aliases

2007-12-11 Thread Stanislav Raskin
] Gesendet: Dienstag, 11. Dezember 2007 19:54 An: Stanislav Raskin Cc: pgsql-general@postgresql.org Betreff: Re: [GENERAL] Understanding Aliases > SELECT-list output aliases name the *output* columns of the SELECT. > Those output columns are not available to the SELECT's computatio

Re: [GENERAL] Understanding Aliases

2007-12-11 Thread Stanislav Raskin
> should do the trick without double select, or? Indeed it seems to do so. The cost estimation is even about 10 times less with the real application's queries. I never really used group/having even though being aware of their existence. I probably should do so more often.

Re: [GENERAL] Understanding Aliases

2007-12-11 Thread Harald Armin Massa
Stanislav, SELECT >t2.id, >(SELECT COUNT(id) FROM t4 WHERE t2_id = t2.id AND value=10) > AS t4_num > FROM >t2 > WHERE >t2.active >AND ( > (SELECT COUNT(id) FROM t4 WHERE t2_id = t2.id AND value=10) <= 3 >) > >

Re: [GENERAL] Understanding Aliases

2007-12-11 Thread Stanislav Raskin
> People frequently think that because ORDER BY can refer to the > output-column aliases, other clauses should be able to do it too, > but this is not so. Thank you very much for clearing that one up. Now I have a follow-up question. Let's assume that I want not only to evaluate a subquery for th

Re: [GENERAL] Understanding Aliases

2007-12-11 Thread Tom Lane
"Stanislav Raskin" <[EMAIL PROTECTED]> writes: > Still no Idea why it does not work with the alias. SELECT-list output aliases name the *output* columns of the SELECT. Those output columns are not available to the SELECT's computation clauses. Otherwise you'd have a logical circularity --- by def

Re: [GENERAL] Understanding Aliases

2007-12-11 Thread Stanislav Raskin
Note to self: works if I directly reference outer query column name from the inner query. Still no Idea why it does not work with the alias.

Re: [GENERAL] Understanding Aliases

2007-12-11 Thread Stanislav Raskin
I messed up a little while reformatting, the error message is of course: ERROR: column "got_t2_id" does not exist _ Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Stanislav Raskin Gesendet: Dienstag, 11. Dezember 2007 12:33 An: pgsql-general@postgresql.org Betre