SQL query to show what has been payed each
Posted
by Tommy Jakobsen
on Stack Overflow
See other posts from Stack Overflow
or by Tommy Jakobsen
Published on 2010-04-18T11:59:55Z
Indexed on
2010/04/18
12:03 UTC
Read the original article
Hit count: 509
I'm looking for help to create a query, to solve the following problem:
Let's imagine the row:
Name StartDate EndDate Payed James 10-10-2010 17-02-2011 860
Now I need a way to split this row up, so I can see what he pays every month, for his period, a query that returns:
Name Year Month Payed James 2010 10 172 James 2010 11 172 James 2010 12 172 James 2011 01 172 James 2010 02 172
There are lots of different customers with different StartDate/EndDate and amount payed, so the query has to handle this aswell. How can I do this in SQL (MS SQL Server 2005)?
Help will be much appreciated!
© Stack Overflow or respective owner