Re: How to convert rows into HTML columns?

From: Michael Glaesemann <grzm(at)seespotcode(dot)net>
To: Stefan Schwarzer <stefan(dot)schwarzer(at)grid(dot)unep(dot)ch>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to convert rows into HTML columns?
Date: 2007-10-05 12:27:43
Message-ID: 6D36D064-897D-4E0A-A55B-57DCAEFA95CB@seespotcode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Oct 5, 2007, at 1:20 , Stefan Schwarzer wrote:

> Before I was used that the yearly values were all to be found in a
> single SQL row; now for each year of each country I have a separate
> row. How do I convert that into a single (HTML) row again?

Take a look at the crosstab functions in contrib/tablefunc.

> And the next question coming up is: How should my query look like
> so that I can sort the (HTML) table by a specific year in ascending
> or descending order? So, that it doesn't display it by the country
> names alphabetical order, but by, say 1998?

Same way you would otherwise -- ORDER BY -- after using crosstab.

Michael Glaesemann
grzm seespotcode net

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Glaesemann 2007-10-05 12:40:17 Re: Find min year and min value
Previous Message Stefan Schwarzer 2007-10-05 12:14:11 Re: Find min year and min value