How to convert rows into HTML columns? - Mailing list pgsql-general

From Stefan Schwarzer
Subject How to convert rows into HTML columns?
Date
Msg-id E01BB01F-53D7-4877-8952-E13EC00297EE@grid.unep.ch
Whole thread Raw
Responses Re: How to convert rows into HTML columns?  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Re: How to convert rows into HTML columns?  (Michael Glaesemann <grzm@seespotcode.net>)
List 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



pgsql-general by date:

Previous
From: "A. Kretschmer"
Date:
Subject: Re: Error while database creation
Next
From: "A. Kretschmer"
Date:
Subject: Re: How to convert rows into HTML columns?