Re: Conditional on Select List - Mailing list pgsql-general

From Joshua D. Drake
Subject Re: Conditional on Select List
Date
Msg-id 4829BBCE.6090409@commandprompt.com
Whole thread Raw
In response to Conditional on Select List  (Fernando <fernando@ggtours.ca>)
List 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


pgsql-general by date:

Previous
From: "Harald Armin Massa"
Date:
Subject: Re: Conditional on Select List
Next
From: Sam Mason
Date:
Subject: Re: Conditional on Select List