How do I revert the summary table grouped by a column to an ungrouped original table? For example;
I have a table, TABLE1, with two columns:
ID, Counts (both integers)
1 2
2 4
3 1
4 2
.....
The result table, TABLE2, should be just one column with each id repeated number of times corresponding to counts column;
ID
1
1
2
2
2
2
3
4
4
...
TABLE1 is the result the following query.
select ID, count(ID) as counts
into TABLE1
from TABLE2
group by ID
I only have TABLE1 and I need to recreate the TABLE2.
I thought I could do this with a simple proc or function but I have been wrestling with this problem for days and deadline is approaching. I need some help.
Any help would be greatly appreciated.
Thanks.
smin.
I have a table, TABLE1, with two columns:
ID, Counts (both integers)
1 2
2 4
3 1
4 2
.....
The result table, TABLE2, should be just one column with each id repeated number of times corresponding to counts column;
ID
1
1
2
2
2
2
3
4
4
...
TABLE1 is the result the following query.
select ID, count(ID) as counts
into TABLE1
from TABLE2
group by ID
I only have TABLE1 and I need to recreate the TABLE2.
I thought I could do this with a simple proc or function but I have been wrestling with this problem for days and deadline is approaching. I need some help.
Any help would be greatly appreciated.
Thanks.
smin.