I have a query that retrieve two columns.
Like this:
select subscription_id, months from subscriptions;
Now, the result is like this:
subscription_id months
1254 4
5896 1
8965 3
I want to add in the result of the query, in the right side, columns dynamically, depends of the number of months that are retrieved. If the result for one record is 4, I'll add for the next 4 columns the value 4 over the same row and so on.
Example:
subscription_id months 0 1 2 3 4 5
1254 4 4 4 4 4 4
5896 1 1 1
8965 3 3 3 3 3 3
NOTE: I'm using Oracle 10g, pivot is not possible to use.