Thanks this is exactly what I need it.
Fernando
Tom Lane wrote:
Fernando <[EMAIL PROTECTED]> writes:
Is it possible to do this?
SELECT IF(COUNT(colname) > 0, TRUE, FALSE) AS colname FROM table;
SELECT COUNT(colname) > 0 AS colname FROM table;
If you really like to type, you could us
On Tue, May 13, 2008 at 8:52 AM, Fernando <[EMAIL PROTECTED]> wrote:
> SELECT IF(COUNT(colname) > 0, TRUE, FALSE) AS colname FROM table;
A rewrite of this query might do what you want:
SELECT colname_cnt > 0 AS Greaterthanzero
FROM ( SELECT COUNT( colname ) AS colname_cnt
FROM Table
On Tue, May 13, 2008 at 11:52 AM, Fernando <[EMAIL PROTECTED]> wrote:
>
> Is it possible to do this?
>
> SELECT IF(COUNT(colname) > 0, TRUE, FALSE) AS colname FROM table;
You should be able to use CASE for this.
-Doug
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To ma
Fernando <[EMAIL PROTECTED]> writes:
> Is it possible to do this?
> SELECT IF(COUNT(colname) > 0, TRUE, FALSE) AS colname FROM table;
SELECT COUNT(colname) > 0 AS colname FROM table;
If you really like to type, you could use a CASE expression.
regards, tom lane
--
Sent
>
> 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 alrea
On Tue, May 13, 2008 at 11:52:24AM -0400, 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
> b
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 cr
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 <[EMAIL PROTECTED]> wrote:
>
>