SQL split number over date range
I have a table with, for example this data ID |start_date |end_date |amount ---|------------|-----------|------- a1 |2013-12-01 |2014-03-31 |100 Iwant to have a query that split the dates so I have the amount splitted out over the year like this : ID |org_start_date |org_end_date |new_start_date |new_end_date |amount ---|----------------|---------------|----------------|----------------|------- a1 |2013-12-01 |2014-03-31 |2013-12-01 |2013-12-31 |25 a1 |2013-12-01 |2014-03-31 |2014-01-01 |2014-03-31 |75 The 25 in 2013 is because 2013 has one month and 75 in 2014 because this has 3 months Is