From: | "Harald Armin Massa" <haraldarminmassa(at)gmail(dot)com> |
---|---|
To: | Fernando <fernando(at)ggtours(dot)ca> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Conditional on Select List |
Date: | 2008-05-13 16:03:21 |
Message-ID: | 7be3f35d0805130903r395a4b2ex18aaef1b76cc8bab@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Fernando,
the "IF" function is called
CASE
WHEN condition THEN result
[WHEN ...]
[ELSE result]
END
read about it at
http://www.postgresql.org/docs/8.3/static/functions-conditional.html
best wishes,
Harald
On Tue, May 13, 2008 at 5:52 PM, Fernando <fernando(at)ggtours(dot)ca> wrote:
>
> Is it possible to do this?
>
> SELECT IF(COUNT(colname) > 0, TRUE, FALSE) AS colname FROM table;
>
> What I want is to return a boolean, but when I tried SELECT
> COUNT(colname)::BOOLEAN FROM table; it says it cannot cast bigint to
> boolean.
>
> Is there such IF function or do I have to create my own.
>
> Thank you.
>
--
GHUM Harald Massa
persuadere et programmare
Harald Armin Massa
Spielberger Straße 49
70435 Stuttgart
0173/9409607
fx 01212-5-13695179
-
EuroPython 2008 will take place in Vilnius, Lithuania - Stay tuned!
From | Date | Subject | |
---|---|---|---|
Next Message | Joshua D. Drake | 2008-05-13 16:03:26 | Re: Conditional on Select List |
Previous Message | Tom Lane | 2008-05-13 15:54:37 | Re: pg_standby / WAL archive-restore through system restarts |