Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Display Previous Row value in Current row.

Kannan SekarJul 2 2019 — edited Jul 2 2019

The below table holds transaction details.

Txn_dateTxn_Amount
6/1/20191000
6/2/20192000
6/5/20193000
6/8/20195000
6/10/20191000

I have another table and its holds Date range (Entire June month 6/1 to 6/30).

Date
6/1/2019
6/2/2019
6/3/2019
6/4/2019
6/5/2019
6/6/2019
6/7/2019
6/8/2019
6/9/2019 .....
.......6/30/2019

Here my requirement is, i need to join these 2 tables and if the transaction date is matching then i display current row txn_amount, if transaction is not happen on particular date then i need to display previous date transaction amount.

Required output:

DateTxn_amount
6/1/20191000
6/2/20192000
6/3/20192000 (transaction is not happens on 3rd june, so i display previous txn date amount)
6/4/20192000 (transaction is not happens on 4th june, so i display previous txn date amount)
6/5/20193000
6/6/20193000 (transaction is not happens on 6th june, so i display previous txn date amount)
6/7/20193000(transaction is not happens on 7th june, so i display previous txn date amount)
6/8/20195000
6/9/20195000 (transaction is not happens on 9th june, so i display previous txn date amount)
6/10/2019........1000
.........6/30/20191000 (after 10th june there is no transaction happens, so all remaining days display last txn amount
This post has been answered by mathguy on Jul 2 2019
Jump to Answer
Comments
Post Details
Added on Jul 2 2019
1 comment
477 views