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!

Trying to Join table to another table with nearest date, Please help

1054420Dec 9 2015 — edited Dec 9 2015

Hi ,

I am trying to get dates from a second table which is has well test results from adhoc dates, My goal is to get these results to table A (which is the daily production table).

Table A (Sample of Daily Transaction table)

WELLID DATE

201 11-Sep-15

201 12-Sep-15

201 13-Sep-15

201 19-Sep-15

502 10-Oct-15

502 10-Nov-15

Table B (Well Test Table)

WELLID TESTDATE YIELDFACTOR

201 10-Aug-15 500

201 10-Sep-15 300

201 11-Oct-15 200

502 10-Aug-15 50

502 7-Oct-15 170

502 15-Oct-15 200

After joining the data should look like below (with all data from the Daily Transactional table and the corresponding nearest Test dates for that particular well

WELLID DATE TESTDATE YIELDFACTOR

201 11-Sep-15 10-Sep-15 300

201 12-Sep-15 10-Sep-15 300

201 13-Sep-15 10-Sep-15 300

201 19-OCT-15 11-Oct-15 200

502 10-Oct-15 7-Oct-15 170

502 11-Oct-15 15-Oct-15 200

how to join with nearest date.jpg Any help is very much appreciated

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 6 2016
Added on Dec 9 2015
1 comment
102 views