Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: Conditional on Select List



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





Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group