Search Postgresql Archives

Re: Conditional on Select List

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 13, 2008 at 8:52 AM, Fernando <fernando@xxxxxxxxxx> 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 );

or

SELECT CASE COUNT( colname )
       WHEN > 0
       THEN TRUE
       ELSE FALSE
       END AS GreaterThanZero
  FROM Table;
-- 
Regards,
Richard Broersma Jr.

Visit the Los Angles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux