I'm trying to write an update
statement in Oracle that will find an attribute from a history table based on a timestamp. So, for example the data looks like:
TABLE A
A_ID TIMESTAMP ATTR
---------------------------------
1 5/27/2012 10:30:00 AM ?
TABLE B
B_ID A_ID TIMESTAMP ATTR
---------------------------------------
1 1 5/26/2012 9:01:08 AM W
2 1 5/27/2012 8:38:21 AM X
3 1 5/28/2012 9:01:01 AM Y
4 1 5/29/2012 11:37:54 PM Z
The lower bound is >= B.TIMESTAMP, but I'm not sure how to write the upper bound as < B."the next TIMESTAMP". So, in the example above the attribute on table A should update to "X".
This seems like a fairly common use case. I've seen this post, but it looks like a satisfactory answer was never reached, so I thought I'd post again.