Re: [HACKERS] Counting bool flags in a complex query - Mailing list pgsql-hackers

From Thomas Lockhart
Subject Re: [HACKERS] Counting bool flags in a complex query
Date
Msg-id 378CB733.EFBCA98F@alumni.caltech.edu
Whole thread Raw
In response to Counting bool flags in a complex query  (Michael Richards <miker@scifair.acadiau.ca>)
Responses Re: [HACKERS] Counting bool flags in a complex query
List pgsql-hackers
> Unless anyone can come up with a better way to do this, What is the best
> way to implement a conversion from bool to int?

Try
 select sum(case when bfield = TRUE then 1 else 0 end) from table;

It works for me...
            - Thomas

-- 
Thomas Lockhart                lockhart@alumni.caltech.edu
South Pasadena, California


pgsql-hackers by date:

Previous
From: Lamar Owen
Date:
Subject: Password redux (was:Re: [HACKERS] Updated TODO list)
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] Interesting behaviour !