I have a table like this:
CUSTOMER DATE QTY
----------------------------
1 2015-10-01 5
1 2015-10-02 4
1 2015-10-03 3
...
2 2015-10-01 9
2 2015-10-02 8
2 2015-10-03 7
...
I want to create a view
(or perhaps a function
) to return records like this:
CUSTOMER "2015-10-01" "2015-10-02" "2015-10-03" ...
--------------------------------------------------------
1 5 4 3
2 9 8 7
I need to return "all dates" in table (but will have the last 60 days tops). But if table has only 10 dates, there will be only 10 columns (plus customer id) and so on...
I tried to use crosstab
function, but it needs to be informed all the "date column names", that (obviously) can vary depending of table contents.