I need to convert following rows:
table {name,col} values{(x,value1), (x , value2) (x , value3) (x , value2) (x , value3) (y , value1) (y , value3) (y , value3) (z , value1)}
into following columns: {name ,value1, value2 , value3} values{(x,1,2, 2), (y, 1, 0 , 2)(z, 1, 0 , 0)} I use the following code but it doesn't know crosstab:
SELECT * FROM crosstab ( 'SELECT name , col, count(col) FROM table GROUP BY name order by name ) AS (name text, value1 integer, value2 integer, value3 integer)