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

From Stefan Schwarzer
Subject Re: Database/Table Design for Global Country Statistics
Date
Msg-id AB2B4194-783E-417B-9153-60EFAA797577@grid.unep.ch
Whole thread Raw
In response to Re: Database/Table Design for Global Country Statistics  (Tino Wildenhain <tino@wildenhain.de>)
Responses Re: Database/Table Design for Global Country Statistics
List 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



pgsql-general by date:

Previous
From: Ron Johnson
Date:
Subject: Re: Database/Table Design for Global Country Statistics
Next
From: Ow Mun Heng
Date:
Subject: Re: Table partitioning based on multiple criterias possible?