Re: doc question about column name alias
От | Tom Lane |
---|---|
Тема | Re: doc question about column name alias |
Дата | |
Msg-id | 15864.993483354@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | doc question about column name alias (Weiping He <laser@zhengmai.com.cn>) |
Ответы |
Re: doc question about column name alias
|
Список | pgsql-docs |
Weiping He <laser@zhengmai.com.cn> writes: > SELECT a AS b FROM table1 ORDER BY a; > I think it should be: > SELECT a AS b FROM table1 ORDER BY b; You are correct that the latter is the SQL-standard version. The former is *also* accepted by Postgres --- but the point the text is trying to make is that "ORDER BY a" is interpreted as a reference to the original column "a", not to the output expression that happens to also reference "a". Perhaps this equivalent situation is a little more clear: SELECT a+b AS c FROM table1 ORDER BY a+b; SELECT a+b AS c FROM table1 ORDER BY c; Both of these are accepted by Postgres; only the second one is SQL92; the first one could cause a+b to be computed twice per row, the second only once per row. (I think that in fact the system will notice that it has duplicate subexpressions here, but that's an optimization.) Feel free to propose improved wording for the English docs ... regards, tom lane
В списке pgsql-docs по дате отправления: