1

I have this situation, I have a table with name->value columns like this

NAME VALUE
ip 12.12.12.12
name Smith
db base
pass 22222

I would like to select this table like this

ip name db pass
12.12.121.2 Smith base 22222

As if the values of column NAME are the column names and the values of the VALUE column are the column values. And the rows are variable, they can be 2 or 22 so if 22 then there should be 22 columns, well each one has a unique name.


I see that crosstab is the solution, so i try this:

select * from crosstab( 'SELECT col1,col2,col3 FROM settings' ) as res (section varchar,naam varchar,value1 text);

But i get ERROR: return and sql tuple descriptions are incompatible. What is wrong with this query?

0

0

Browse other questions tagged or ask your own question.