How to use result column names in having cause - Mailing list pgsql-general

From Andrus
Subject How to use result column names in having cause
Date
Msg-id e0j5qm$1fls$1@news.hub.org
Whole thread Raw
Responses Re: How to use result column names in having cause  ("chris smith" <dmagick@gmail.com>)
List 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 by date:

Previous
From: Kai Hessing
Date:
Subject: Re: Performance Killer 'IN' ?
Next
From: "chris smith"
Date:
Subject: Re: How to use result column names in having cause