1

I want to create a pivot table from the following dataset:

dataset1

The ids repeat every 252nd row with new dates and different quantities:

dataset1cont

I wanted a pivot table similar to this: desired-pivot

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
  • 2
    [Why may I not upload images of code on SO when asking a question?](http://meta.stackoverflow.com/questions/285551/why-may-i-not-upload-images-of-code-on-so-when-asking-a-question/285557#285557) – klin Nov 01 '16 at 19:44
  • maybe you'll find help here: http://stackoverflow.com/questions/22052334/postgresql-says-return-and-sql-tuple-descriptions-are-incompatible – McNets Nov 01 '16 at 22:21

0 Answers0