Re: Database/Table Design for Global Country Statistics - Mailing list pgsql-general

From Richard Huxton
Subject Re: Database/Table Design for Global Country Statistics
Date
Msg-id 46E94732.8040206@archonet.com
Whole thread Raw
In response to Re: Database/Table Design for Global Country Statistics  (Stefan Schwarzer <stefan.schwarzer@grid.unep.ch>)
Responses Re: Database/Table Design for Global Country Statistics  (Stefan Schwarzer <stefan.schwarzer@grid.unep.ch>)
List pgsql-general
Stefan Schwarzer wrote:
> Just for the completeness, I attach the final working SQL query:
>
> SELECT
>   f.year,
>   f.id,
>   c.name,
>   (f.value / p.value) AS per_capita
> FROM
>   fish_catch AS f
> JOIN
>   pop_total AS p
> USING
>    (year, id)
> INNER JOIN
>    countries AS c ON f.id = c.id
> ORDER BY
>    year

Make sure you fully specify the order:
   ORDER BY year, f.id, c.name
It might work by chance a few times, but then return rows in an
unexpected order later.

--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

Previous
From: Stefan Schwarzer
Date:
Subject: Re: Database/Table Design for Global Country Statistics
Next
From: Stefan Schwarzer
Date:
Subject: Data Model - Linking to PHP Code - Literature