pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Paul Ramsey <pramsey@refractions.net>
To: pgsql-sql@postgresql.org
Subject: Booleans and Casting
Date: Fri, 12 Feb 1999 13:33:08 -0800
Message-ID: <36C49E14.84C93DA5@refractions.net> (raw)

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@refractions.net
     | Phone: (250) 885-0632
     \_



view thread (2+ messages)  latest in thread

Message-ID: <36C49E14.84C93DA5@refractions.net>
Permalink:  ../36C49E14.84C93DA5@refractions.net/
Also on:    postgresql.org/message-id/36C49E14.84C93DA5@refractions.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: pramsey@refractions.net
  Subject: Re: Booleans and Casting
  In-Reply-To: <36C49E14.84C93DA5@refractions.net>
  References: <36C49E14.84C93DA5@refractions.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox