How to use result column names in having cause

From: "Andrus" <eetasoft(at)online(dot)ee>
To: pgsql-general(at)postgresql(dot)org
Subject: How to use result column names in having cause
Date: 2006-03-31 12:03:25
Message-ID: e0j5qm$1fls$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message chris smith 2006-03-31 12:18:47 Re: How to use result column names in having cause
Previous Message Kai Hessing 2006-03-31 11:01:00 Re: Performance Killer 'IN' ?