Re: Conditional on Select List

From: "Adam Rich" <adam(dot)r(at)sbcglobal(dot)net>
To: "'Fernando'" <fernando(at)ggtours(dot)ca>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Conditional on Select List
Date: 2008-05-13 16:07:09
Message-ID: 008201c8b513$663d2b30$32b78190$@r@sbcglobal.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>
> 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.
>

How about this? Logic
al expresses are already returned as Boolean.

Select COUNT(colname) > 0 AS colname FROM table

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-05-13 16:07:37 Re: Conditional on Select List
Previous Message J. Manuel Velasco - UBILIBET 2008-05-13 16:05:48 Re: how can i get initdb