Rows to columns - Mailing list pgsql-general

From Josué Maldonado
Subject Rows to columns
Date
Msg-id 403B9BC3.3070506@lamundial.hn
Whole thread Raw
Responses Re: Rows to columns  (Joe Conway <mail@joeconway.com>)
List 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




pgsql-general by date:

Previous
From: Sean Shanny
Date:
Subject: Re: Found this in the server log on MAC OSX
Next
From: Joe Conway
Date:
Subject: Re: Rows to columns