| От | Tom Lane |
|---|---|
| Тема | Re: syntax for access an alias in the where clause ? |
| Дата | |
| Msg-id | 7447.1024521796@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | syntax for access an alias in the where clause ? (Michael Agbaglo <byteshifter@shifted-bytes.de>) |
| Список | pgsql-sql |
Michael Agbaglo <byteshifter@shifted-bytes.de> writes:
> select [expression 1] as [alias 1], [expression 2] as [alias 2]
> where [alias 1] < [alias 2]
> order by [alias 2] - [alias 1]
> ---> ERROR: Attribute '[alias 1]' not found
> I found a lot of 'select [expression] as' but I've never seen somebody
> accessing the alias ... Can't this be done ?
No, it can't, and the reason is that the WHERE clause is logically
evaluated before the SELECT list is (in fact, the SELECT list will
never be evaluated at rows where the WHERE clause returns false).
It would be circular to refer to SELECT outputs in WHERE.
regards, tom lane
В списке pgsql-sql по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера