gda,
BEGIN;
create extension tablefunc;
create table t as
WITH t (sub_name,document_id, result) AS (values
('DEALER Amenities'::text, 3930177::int, 96.3::double precision)
,('DESIGN - Amenties Packages', 3930178 , 97.5)
,('PRODUCT - Inquiry - Negative', 3930179 , 92.9)
)
SELECT * FROM t
;
select *
from crosstab(
'select sub_name, ''c''||document_id::text, result
from t
order by 1, 2'
,'SELECT ''c''||document_id::text FROM t')
as vw_doc_with_result(sub_name text, c3930177 double precision, c3930178 double precision, c3930179 double precision);
--------------
'DEALER Amenities',96.3,,
'DESIGN - Amenties Packages',,97.5,
'PRODUCT - Inquiry - Negative',,,92.9