Re: Database/Table Design for Global Country Statistics

From: Stefan Schwarzer <stefan(dot)schwarzer(at)grid(dot)unep(dot)ch>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Database/Table Design for Global Country Statistics
Date: 2007-09-12 09:35:01
Message-ID: AB2B4194-783E-417B-9153-60EFAA797577@grid.unep.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks for the feedback and the suggestions.

A problem I have now when using the new design is the following:

As a result from my PostGres query I get something like this:

year | value | name
---------------------------------------
2001 | 123 | Afghanistan
2002 | 125 | Afghanistan
2003 | 128 | Afghanistan
2004 | 132 | Afghanistan
2005 | 135 | Afghanistan

2001 | 412 | Albania
2002 | 429 | Albania
2003 | 456 | Albania
2004 | 465 | Albania
2005 | 477 | Albania

.....

The way it is displayed on the web (in table form) is the "usual" way:

name 2001 2002 2003 2004 2005
-----------------------------------------------------------------
Afghanistan ....
Albania ....

Is there any "simple", elegant solution for PHP, so that it does this
transformation? I can't imagine that I would have to write a couple
of IFs to achieve that. But I have no other idea. Or is it a question
of writing a more elegant SQL query?

Thanks for any advice!

Stef

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ow Mun Heng 2007-09-12 09:39:32 Re: Table partitioning based on multiple criterias possible?
Previous Message Ron Johnson 2007-09-12 09:28:31 Re: Database/Table Design for Global Country Statistics