I want to create a pivot table from the following dataset:
The ids repeat every 252nd row with new dates and different quantities:
I wanted a pivot table similar to this:
I'm running the following query to get the pivot table:
select * from crosstab(
'select id, thedate, quantity
from mytable
order by 1,2'
) as t(id integer, thedate timestamp)
But I'm getting the following error:
ERROR: return and sql tuple descriptions are incompatible
SQL state: 42601