How to convert rows into HTML columns?

From: Stefan Schwarzer <stefan(dot)schwarzer(at)grid(dot)unep(dot)ch>
To: pgsql-general(at)postgresql(dot)org
Subject: How to convert rows into HTML columns?
Date: 2007-10-05 06:20:32
Message-ID: E01BB01F-53D7-4877-8952-E13EC00297EE@grid.unep.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi there,

I feel like a brain-washed person being slowly re-socialized. After
changing from an Excel-like database design to a "central table" one
(see here: http://archives.postgresql.org/pgsql-general/2007-10/
msg00132.php ) I am struggling with multiple problems...

One is now the HTML table display of a simple SELECT :

SELECT
d.year,
d.value,
c.name AS country_name
FROM
public_one_table.data AS d
LEFT JOIN
countries AS c ON c.id = id_country
WHERE
id_variable = 1644 AND
(year = '2000' OR year = '1999' OR year = '1998')
ORDER BY
country_name ASC

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?

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?

Thanks for any help!

Stef

Responses

Browse pgsql-general by date

  From Date Subject
Next Message A. Kretschmer 2007-10-05 06:56:42 Re: How to convert rows into HTML columns?
Previous Message A. Kretschmer 2007-10-05 06:19:56 Re: Error while database creation