Say I have a table with the following data, and I want to group by customer_id.
| 'customer_id' | 'date_of_purchase' |
|---------------|--------------------|
| AAA           | '2019-01-01'       |
| AAA           | '2019-02-01'       |
| AAA           | '2019-03-01'       |
| BBB           | '2019-01-20'       |
| BBB           | '2019-02-20'       |
| CCC           | '2019-01-01'       |
| CCC           | '2019-03-10'       |
| CCC           | '2019-05-10'       |
| CCC           | '2019-08-10'       |
My endgoal is to have a table where each customer_id gets a row, with variable number of columns. Something that looks like this
| customer_id | some header  | some header  | some header  | some header  |
|-------------|--------------|--------------|--------------|--------------|
| AAA         | '2019-01-01' | '2019-02-01' | '2019-03-01' |              |
| BBB         | '2019-01-20' | '2019-02-20' |              |              |
| CCC         | '2019-01-01' | '2019-03-10' | '2019-05-10' | '2019-08-10' |
I'm not sure if crosstab() can accomplish this task. Is this even possible in postgresql?
Thanks in advance for the help
