Re: Data format and display - Mailing list pgsql-general

From Tom Lane
Subject Re: Data format and display
Date
Msg-id 24819.1106423892@sss.pgh.pa.us
Whole thread Raw
In response to Data format and display  (Josué Maldonado <josue@lamundial.hn>)
List pgsql-general
=?ISO-8859-1?Q?Josu=E9_Maldonado?= <josue@lamundial.hn> writes:
> I have a table that contains this raw data:

>   epr_procode | epr_tipo | epr_mes | epr_valor |      zert_title
> -------------+----------+---------+-----------+----------------------
>   00C188      | VTA      | 200309  | 2116.0000 | Venta
>   00C188      | CTO      | 200309  | 1600.0700 | Costo
>   00C188      | VTA      | 200311  | 3450.0000 | Venta
>   00C188      | CTO      | 200311  | 2687.4200 | Costo

> I need to display it this way:

> TITULO         |200309    |200310   |200311     |200312
> -------------+----------+---------+-----------+----------------------
> Venta         |2116.0000 |0.0000   |3450.0000  |0.0000
> Costo         |1600.0700 |0.0000   |2687.4200  |0.0000

I think the "crosstab" functions in contrib/tablefunc/ might help you.

            regards, tom lane

pgsql-general by date:

Previous
From: Chris
Date:
Subject: SCHEMA compatibility with Oracle/DB2/Firebird
Next
From: "Ed L."
Date:
Subject: pg SQL question