To get difference between 2 rows and the resultant value into the latest row’s column.
Folks,
Here is how the data looks like:
Loan_table
AC_NUM DATE AMT DIFF
0001 12-31-2001 1000 0
0001 01-31-2002 3000 2000
In the above table, what I need to do is get the value from the AMT column for the MAX(DATE). Then I need to get the previous months AMT, in this case 1000, do a subtraction from current month (3000) – previous month (1000) and post the difference of 2000 in the last row with the max date. Can this be done by doing a JOIN or a subselect. Please post the SQL query. How do I go about accomplishing this?
All help will be greatly appreciated.
Paul
Folks,
Here is how the data looks like:
Loan_table
AC_NUM DATE AMT DIFF
0001 12-31-2001 1000 0
0001 01-31-2002 3000 2000
In the above table, what I need to do is get the value from the AMT column for the MAX(DATE). Then I need to get the previous months AMT, in this case 1000, do a subtraction from current month (3000) – previous month (1000) and post the difference of 2000 in the last row with the max date. Can this be done by doing a JOIN or a subselect. Please post the SQL query. How do I go about accomplishing this?
All help will be greatly appreciated.
Paul