Re: BUG #14079: Issues with query

Поиск
Список
Период
Сортировка
От Hector Bejarano
Тема Re: BUG #14079: Issues with query
Дата
Msg-id CAAT+ugrN-w_RDnfSKKOXTOhFT0BxR=wJv_pDucKDeruvjzKvxA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: BUG #14079: Issues with query  (Phillip Couto <phillip.couto01@gmail.com>)
Ответы Re: BUG #14079: Issues with query  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-bugs
Right, this explains the how but not the why, which is really my question.
For instance, there are other statements I can use with this derived column
like a group by:

select 1 as a group by a

But then if I try to use "having" then it fails just like it does with the
WHERE clause:

select 1 as a group by a having a=1

See, the thing here is I don't understand WHY it was designed this way,
because to me it would be very useful to have the ability to use the
derived column without having to wrap the whole thing in a derived query.

On Fri, Apr 8, 2016 at 4:53 PM, Phillip Couto <phillip.couto01@gmail.com>
wrote:

> The WHERE is executed before the SELECT. The value of a is not available
> to the WHERE clause as it is assigned at the end of the query.
>
> To actually make your query work it would have to read:
> select * from (select 1 as a) as b where a = 1
>
> The from provides the data that the where will operate on, the select then
> determines what to be returned.
>
> On Fri, 8 Apr 2016 at 18:41 <hector.bejarano@gmail.com> wrote:
>
>> The following bug has been logged on the website:
>>
>> Bug reference:      14079
>> Logged by:          Hector Bejarano
>> Email address:      hector.bejarano@gmail.com
>> PostgreSQL version: 9.5.0
>> Operating system:   Ubuntu 14
>> Description:
>>
>> This query works:
>> select 1 as a
>>
>> But this one fails:
>> select 1 as a where a = 1
>>
>> And I think they should both work.
>>
>> Regards,
>> Hector.
>>
>>
>> --
>> Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-bugs
>>
>

В списке pgsql-bugs по дате отправления:

Предыдущее
От: jack@fastly.com
Дата:
Сообщение: BUG #14080: JSONB order changes when using json_pretty()
Следующее
От: cgh_chen@126.com
Дата:
Сообщение: BUG #14081: System LC_COLLATE changed