[GENERAL] Calculate a quotient for a count of boolean values (true or false)

2013-06-11 Thread Alexander Farber
Hello! In a PostgreSQL 8.4.13 why doesn't this please deliver a floating value (a quotient between 0 and 1): select id, count(nullif(nice, false)) - count(nullif(nice, true)) / count(nice) as rating from pref_rep where nice is not null group by id ; id

Re: [GENERAL] Calculate a quotient for a count of boolean values (true or false)

2013-06-11 Thread Alban Hertroys
Because you're calculating a - (b/c) instead of (a-b)/c On 11 June 2013 11:51, Alexander Farber alexander.far...@gmail.com wrote: Hello! In a PostgreSQL 8.4.13 why doesn't this please deliver a floating value (a quotient between 0 and 1): select id, count(nullif(nice,

Re: [GENERAL] Calculate a quotient for a count of boolean values (true or false)

2013-06-11 Thread Alexander Farber
Hello, On Tue, Jun 11, 2013 at 11:59 AM, Alban Hertroys haram...@gmail.com wrote: Because you're calculating a - (b/c) instead of (a-b)/c On 11 June 2013 11:51, Alexander Farber alexander.far...@gmail.com wrote:

Re: [GENERAL] Calculate a quotient for a count of boolean values (true or false)

2013-06-11 Thread Albe Laurenz
Alexander Farber wrote: In a PostgreSQL 8.4.13 why doesn't this please deliver a floating value (a quotient between 0 and 1): select id, count(nullif(nice, false)) - count(nullif(nice, true)) / count(nice) as rating from pref_rep where nice is not null

Re: [GENERAL] Calculate a quotient for a count of boolean values (true or false)

2013-06-11 Thread Vik Fearing
Whoops, forgot to keep it on the list. On 06/11/2013 11:51 AM, Alexander Farber wrote: Hello! In a PostgreSQL 8.4.13 why doesn't this please deliver a floating value (a quotient between 0 and 1): You should upgrade to 8.4.17. select id, count(nullif(nice, false)) -