Hello,

OK
select 1 as ccc where 1=1

ERROR
select 1 as ccc where ccc=1
PostgreSQL said: ERROR: Attribute 'ccc' not found

Is there any way to set conditions on calculated fields values?

Best regards,
Yar



Wed, 30 Oct 2002 14:48:19 +0300 (MSK)
"Yaroslav Dmitriev" <yar@warlock.ru>
calculated fields are not seen in the WHERE clause
Yaroslav Dmitriev kirjutas K, 30.10.2002 kell 13:48:
> Hello,
> 
> OK
> select 1 as ccc where 1=1
> 
> ERROR
> select 1 as ccc where ccc=1
> PostgreSQL said: ERROR: Attribute 'ccc' not found
> 
> Is there any way to set conditions on calculated fields values?

You could try using a subquery

select *
 from
 (select 1 as ccc) sub
 where ccc=1

---------------
Hannu


30 Oct 2002 14:03:25 +0200
Hannu Krosing <hannu@tm.ee>
Re: calculated fields are not seen in the WHERE clause

AS strings are labels, not columns that can be referenced in a where
clause:

	test=> select lanname as xx from pg_language where xx = 'yy';

Hannu is correct that making a FROM entry works.

---------------------------------------------------------------------------

Hannu Krosing wrote:
> Yaroslav Dmitriev kirjutas K, 30.10.2002 kell 13:48:
> > Hello,
> > 
> > OK
> > select 1 as ccc where 1=1
> > 
> > ERROR
> > select 1 as ccc where ccc=1
> > PostgreSQL said: ERROR: Attribute 'ccc' not found
> > 
> > Is there any way to set conditions on calculated fields values?
> 
> You could try using a subquery
> 
> select *
>  from
>  (select 1 as ccc) sub
>  where ccc=1
> 
> ---------------
> Hannu
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
> 

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Fri, 1 Nov 2002 19:39:07 -0500 (EST)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: calculated fields are not seen in the WHERE clause