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 > boolean. Why not just do something like this? SELECT COUNT(colname) > 0 AS colname FROM table; If you want a real conditional statement, CASE is probably what you want: SELECT CASE WHEN COUNT(colname) > 0 THEN TRUE ELSE FALSE END AS colname FROM table; Note that the ELSE clause is executed when the expression evaluates to either NULL or FALSE, but because COUNT never returns a NULL value it doesn't matter here. It's also possible to have multiple WHEN clauses. Sam