lkrishna
asked on
sql query to fetch previous rows value - 1 in the next column
I have to create a loan account statement in the main report.
In the footnote I need to show the rate of interest changes during the period of account statement as below.
From_date To_date Rate of Interest
1.4.2010 28.5.2010 16.5%
29.5..2010 9.9.2010 15.75
10.9.2010 16.,25
In the above report 'From_date' and 'ROI' are fetched from the table.
Please help to fetch to_date with value= next(from_date) -1
In the footnote I need to show the rate of interest changes during the period of account statement as below.
From_date To_date Rate of Interest
1.4.2010 28.5.2010 16.5%
29.5..2010 9.9.2010 15.75
10.9.2010 16.,25
In the above report 'From_date' and 'ROI' are fetched from the table.
Please help to fetch to_date with value= next(from_date) -1
ASKER
The table has only from_date and ROI fields, I need to fetch the to_date
For e.g. in the below report, to_date in the first row is equal to from_date of second row - 1
29.5.2010 -1,
I tried with self join, connect by prior...but yet to get a solution
From_date To_date Rate of Interest
1.4.2010 28.5.2010 16.5%
29.5..2010 9.9.2010 15.75
10.9.2010 16.,25
For e.g. in the below report, to_date in the first row is equal to from_date of second row - 1
29.5.2010 -1,
I tried with self join, connect by prior...but yet to get a solution
From_date To_date Rate of Interest
1.4.2010 28.5.2010 16.5%
29.5..2010 9.9.2010 15.75
10.9.2010 16.,25
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Isn't that pretty much what I posted?
>>The table has only from_date and ROI fields, I need to fetch the to_date
to_date isn't a real column. It is derived as 1 - the 'next' from date.
>>The table has only from_date and ROI fields, I need to fetch the to_date
to_date isn't a real column. It is derived as 1 - the 'next' from date.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
All the comments are useful and I was able to get the results successfully
ASKER
all the expert comments are useful and I was able toget the required results. Regret for not having responded , due to work pressure in the office ,immediately could not respond.
I'm also not sure what you mean by 'next(from_date)-1'
To add or subtract days from Oracle dates, just do it:
select to_date('1.4.2010','MM.DD.