Trying to do something very simple and calculate the signup_flow rate by mailing.
I have a column called signup_flow
- each row has an integer value of either 1 or 0. Trying to calculate the rate of signup_flow per mailing.
I am using the following query. SUM(signup_flow)
and COUNT(signup_flow)
return the correct values per mailing. When I try to do a simple calculated field (sum/count*100)
it returns 0. This is my first time working with Postgres, does it not support calculations?
SELECT mailing, SUM(signup_flow), COUNT(signup_flow),
((SUM(signup_flow)/COUNT(signup_flow))*100) AS rate
FROM mail_2017_analytic_file
GROUP BY mailing;
Results:
mailing sum count rate
DEC 17 RRD Mailing 2535 1085476 0
JAN 17 RRD Mailing 8275 3695017 0
MAR 17 RRD Mailing 7230 3595594 0
MAY 17 RRD Mailing 5616 2672981 0
JULY 17 RRD Mailing 7837 3741944 0
AUG 17 RRD Mailing 9272 4604807 0
OCT 17 RRD Mailing 7982 4996146 0