Re: [HACKERS] Counting bool flags in a complex query

Поиск
Список
Период
Сортировка
От Thomas Lockhart
Тема Re: [HACKERS] Counting bool flags in a complex query
Дата
Msg-id 378CB733.EFBCA98F@alumni.caltech.edu
обсуждение исходный текст
Ответ на Counting bool flags in a complex query  (Michael Richards <miker@scifair.acadiau.ca>)
Ответы Re: [HACKERS] Counting bool flags in a complex query  (Michael Richards <miker@scifair.acadiau.ca>)
Список 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 по дате отправления:

Предыдущее
От: Lamar Owen
Дата:
Сообщение: Password redux (was:Re: [HACKERS] Updated TODO list)
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] Interesting behaviour !