Calculate the ratio

From: Andreas Forø Tollefsen <andreasft(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Calculate the ratio
Date: 2011-08-15 12:21:34
Message-ID: CAGMz7DnkL2=VxpYqEsqTnMS=MTyDywgu_Z+b79X9ugqn5BgHpg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi all,

This is probably quite simple. I want to calculate the ratio of each country
(gwcode) which experiences a 1 in one column (cf).

Structure:

gid; gridyear; gwcode; area; cf

I want to select the SUM(area) WHERE cf = 1 into one column, and SUM(area)
WHERE cf = 0 into another column and group by gridyear and gwcode.
Then i can see the ratio of the area of each country affected by cf.

Any suggestions?

Thanks.

A.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message msi77 2011-08-15 13:00:37 Re: Calculate the ratio
Previous Message Janiv Ratson 2011-08-15 06:23:08 Re: bigint and unix time