Skip site navigation (1) Skip section navigation (2)

using calculated column in where-clause

From: Patrick Scharrenberg <pittipatti(at)web(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: using calculated column in where-clause
Date: 2008-06-17 20:46:08
Message-ID: 48582290.6050402@web.de (view raw or flat)
Thread:
Lists: pgsql-sql
Hi!

I'd like to do some calculation with values from the table, show them a
new column and use the values in a where-clause.

Something like this
select a, b , a*b as c from ta where c=2;

But postgresql complains, that column "c" does not exist.

Do I have to repeat the calculation (which might be even more complex
:-) ) in the "where"-clause, or is there a better way?


Thanks in advance.

Best regards
Patrick

Responses

pgsql-sql by date

Next:From: Andreas KretschmerDate: 2008-06-17 21:10:41
Subject: Re: using calculated column in where-clause
Previous:From: TJ O'DonnellDate: 2008-06-17 00:24:49
Subject: cool code_swarm animation of PostgreSQL development since 1996

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group