Question: Table has aggregated values but i need to return multiple rows if the value is greater than one. 

Here is how the table looks now:

```
date  description   amount

1/1/2015   alpha    3

1/1/2015    beta    1

```

Here is how i need it to return:

```
date    description amount

1/1/2015    alpha   1

1/1/2015    alpha   1

1/1/2015    alpha   1

1/1/2015    beta    1

```

Any help would be greatly appreciated.

Answer: 
You need a table of numbers. Something like this works for up to 3 and can be easily extended:

```
select t.date, t.description, 1 as amount
from table t join
     (select 1 as n union all select 2 union all select 3) n
     on n.n <= t.amount;

```

EDIT:

If you have enough rows in the table for the larger amounts, you can do:

```
select t.date, t.description, 1 as amount
from table t join
     (select @rn := @rn + 1 as n
      from table cross join (select @rn := 0) vars
     ) n
     on n.n <= t.amount;

```
This worked perfectly.

select t.date, t.description, 1 as amount
from table t join
 (select @rn := @rn + 1 as n
 from table cross join (select @rn := 0) vars
 ) n
 on n.n <= t.amount;