该value
列类型bigint
,而不是date
:
SELECT * FROM crosstab( 'select region, date, sum from data order by 1' ) AS result (region text, d1 bigint, d2 bigint, d3 bigint); region | d1 | d2 | d3 --------+----+----+---- East | 22 | 32 | 12 North | 34 | 88 | South | 52 | 54 | 11 West | 15 | 37 | 11 (4 rows)