How to use result column names in having cause

Поиск
Список
Период
Сортировка
От Andrus
Тема How to use result column names in having cause
Дата
Msg-id e0j5qm$1fls$1@news.hub.org
обсуждение исходный текст
Ответы Re: How to use result column names in having cause  ("chris smith" <dmagick@gmail.com>)
Список pgsql-general
CREATE TEMP TABLE foo( bar integer );

SELECT 123 AS x
  FROM foo
  GROUP BY 1
  HAVING x> AVG(bar)

causes

ERROR:  column "x" does not exist

Why ? How to make this working ?

In real application I have long expression instead of 123 and do'nt want
 repeat this expression in HAVING clause.

In VFP this select works OK.

Andrus.



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

Предыдущее
От: Kai Hessing
Дата:
Сообщение: Re: Performance Killer 'IN' ?
Следующее
От: "chris smith"
Дата:
Сообщение: Re: How to use result column names in having cause