From: | "J(dot)Fernando Moyano" <txinete(at)wanadoo(dot)es> |
---|---|
To: | PgSQL-SQL <pgsql-sql(at)postgresql(dot)org> |
Subject: | Fwd: Re: sum(bool)? |
Date: | 2001-02-25 21:26:28 |
Message-ID: | 01022522262800.01616@txino.mikasa.eh |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
El Viernes 23 Febrero 2001 16:22, escribiste:
> hi there,
>
> i want to add up the "true" values of a comparison like
>
> sum(a>b)
>
> it just doesn't work like this
>
> any workaround?
>
> it is postgresql 7.0 under linux
>
> thanks
>
> olaf
I did exactly the same thing two months ago ....
I created this tiny function:
CREATE FUNCTION bool2int(bool) RETURNS integer
AS 'select (case when $1=true then 1 else 0 end)'
LANGUAGE 'sql';
You can do: sum(bool2int(a>b))
easy ??? ;-))
--
Fernando Moyano
Frase del día:
--------------
El medico me prohibio beber wiski, ahora lo congelo y me lo como!
(*) SymeX ==> http://symex.lantik.com
(*) WDBIL ==> http://wdbil.sourceforge.net
(*) Informate sobre LINUX en http://www.linux.org
From | Date | Subject | |
---|---|---|---|
Next Message | D'Arcy J.M. Cain | 2001-02-25 23:54:03 | Re: Fwd: Re: sum(bool)? |
Previous Message | Lotus118 | 2001-02-25 21:02:18 | distinct date problem |