Re: Conditional on Select List

From: "Joshua D(dot) Drake" <jd(at)commandprompt(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:26
Message-ID: 4829BBCE.6090409@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

Look up CASE in the docs..

Joshua D. Drake

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sam Mason 2008-05-13 16:04:17 Re: Conditional on Select List
Previous Message Harald Armin Massa 2008-05-13 16:03:21 Re: Conditional on Select List