Booleans and Casting

From: Paul Ramsey <pramsey(at)refractions(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Booleans and Casting
Date: 1999-02-12 21:33:08
Message-ID: 36C49E14.84C93DA5@refractions.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I have the following SQL statement, which doesn't work (though I wish it
did):

select sum(value * ( plulabel = 'FO' )) from btmm group by gis_tag;

PG quite correctly complains that:

ERROR: There is more than one possible operator '*' for types
'float4' and 'bool' You will have to retype this query using an explicit
cast

However, when I do this:

select sum(value * int( plulabel = 'FO' )) from btmm group by gis_tag;

I still get an error:

ERROR: No such function 'int' with the specified attributes

I can find no function at all to use to cast booleans to what I want,
which is 1 = true, 0 = false (IE, the standard cast for boolean ->
number).

Any advice?

--
__
/
| Paul Ramsey
| Refractions Research
| Email: pramsey(at)refractions(dot)net
| Phone: (250) 885-0632
\_

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message pierre 1999-02-13 01:03:42 connection timeout?
Previous Message Jan Wieck 1999-02-12 19:16:57 Re: [HACKERS] RULE (and ALTER TABLE) questions