Quantcast
Channel: Question and Answer » postgresql
Viewing all articles
Browse latest Browse all 1138

Add fields to view from select (transpose fields)

$
0
0

I’ve got a table with following structure:

CREATE TABLE test
(
  id integer,
  field character varying, 
  value character varying
);

field     value
------    -----
field1    value1
field2    value2
field3    value3
...       ...

I need to transpose the field value as the fields in a view and the value of the field with be the “value” field’s value. Example of what I need:

field1    field2    field3      ...
------    -----     ------      ----
value1    value2    value3      ...

I have no idea on how to start building the create view statement.


Viewing all articles
Browse latest Browse all 1138

Latest Images

Trending Articles



Latest Images