All,
I have a table that contains balances for certain accounts by date. At certain intervals, a new record is added for each account. I am trying to measure the intervals for each record (basically, the number of days since the last balance).
The data looks like this:
BalanceID AccountID BalanceDate Balance
1 1 10/1/08 100
2 1 9/29/08 150
3 1 9/15/08 100
4 2 10/30/08 500
5 2 10/15/08 600
6 2 10/7/08 500
So what I would like to do is basically write a query that would give me a column that would indicate the number of days since the last time it was balanced, like so:
BalanceID AccountID BalanceDate Balance LastBalanceDate DaysSinceLast
1 1 10/1/08 100 9/29/08 2
2 1 9/29/08 150 9/15/08 14
3 1 9/15/08 100 N/A N/A
4 2 10/30/08 500 10/15/08 15
5 2 10/15/08 600 10/7/08 8
6 2 10/7/08 500 N/A N/A
Thanks!!
I have a table that contains balances for certain accounts by date. At certain intervals, a new record is added for each account. I am trying to measure the intervals for each record (basically, the number of days since the last balance).
The data looks like this:
BalanceID AccountID BalanceDate Balance
1 1 10/1/08 100
2 1 9/29/08 150
3 1 9/15/08 100
4 2 10/30/08 500
5 2 10/15/08 600
6 2 10/7/08 500
So what I would like to do is basically write a query that would give me a column that would indicate the number of days since the last time it was balanced, like so:
BalanceID AccountID BalanceDate Balance LastBalanceDate DaysSinceLast
1 1 10/1/08 100 9/29/08 2
2 1 9/29/08 150 9/15/08 14
3 1 9/15/08 100 N/A N/A
4 2 10/30/08 500 10/15/08 15
5 2 10/15/08 600 10/7/08 8
6 2 10/7/08 500 N/A N/A
Thanks!!