From: | Alban Hertroys <haramrae(at)gmail(dot)com> |
---|---|
To: | Alexander Farber <alexander(dot)farber(at)gmail(dot)com> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Calculate a quotient for a count of boolean values (true or false) |
Date: | 2013-06-11 09:59:55 |
Message-ID: | CAF-3MvMJOrBU_V0CxkAMH=RqwfYm73uWOzptyhbuTRO0b7qCdQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Because you're calculating a - (b/c) instead of (a-b)/c
On 11 June 2013 11:51, Alexander Farber <alexander(dot)farber(at)gmail(dot)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, false)) - count(nullif(nice, true)) /
> count(nice) as rating
> from pref_rep where nice is not null
> group by id
> ;
> id | rating
> -------------------------+--------
> DE10072 | -1
> DE10086 | 18
> DE10087 | 1
> DE10088 | -1
> DE10095 | 276
> DE10097 | 37
> DE10105 | 5
>
> I am trying to calculate a sum of ratings
> given by users to each other
> to draw a pie chart in a game, more details here:
>
>
> http://stackoverflow.com/questions/17040692/calculate-a-quotient-in-one-table-and-store-it-in-another-table
>
> Thank you
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
--
If you can't see the forest for the trees,
Cut the trees and you'll see there is no forest.
From | Date | Subject | |
---|---|---|---|
Next Message | Alexander Farber | 2013-06-11 10:33:13 | Re: Calculate a quotient for a count of boolean values (true or false) |
Previous Message | Alexander Farber | 2013-06-11 09:51:40 | Calculate a quotient for a count of boolean values (true or false) |