Rows to columns

From: Josué Maldonado <josue(at)lamundial(dot)hn>
To: pgsql-general(at)postgresql(dot)org
Subject: Rows to columns
Date: 2004-02-24 18:45:23
Message-ID: 403B9BC3.3070506@lamundial.hn
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello List,

I have a table that look like this:

create table estad
(nprodfk int, cmes char(6), hmes char(5),
nqty numeric(12,2), nsold numeric(12,5),
ncost numeric(12,2));

It contains this data:

insert into estad
values (25,'200402','FEB04',500,5000,2300);

insert into estad
values (25,'200401','ENE04',700,6200,2900);

insert into estad
values (25,'200312','DIC03',950,7100,3000);

insert into estad
values (25,'200311','NOV03',360,3900,1760);

insert into estad
values (25,'200310','OCT03',490,4600,1850);

The problem is I need show the data in this way:

TIPO OCT03 NOV03 DIC03 ENE04 FEB04
--------------------------------------------------------
NQTY 490 360 950 700 500
NSOLD 4600 3900 7100 6200 5000
NCOST 1850 1760 3000 2900 2300

Any idea or suggestion?

Thanks in advanced.

--

Josué Maldonado

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joe Conway 2004-02-24 19:00:56 Re: Rows to columns
Previous Message jake johnson 2004-02-24 18:40:30 Irreversible performance drop after increasing shared mem