I've got a simple example table with the following structure:
PK_ID | PK_VALID_FROM_DATE | VALUE
------+--------------------+------
1 | "1980-01-01" | 42
1 | "1999-06-06" | 103
2 | "2011-12-12" | 92
1 | "2014-04-04" | 512
The table is created by adding a row, on each date the value changes.
Or is there any better way to create a history of the date when a value was changed and look it up?
Now I want to query to find out which VALUE was valid on a particular date for a particular PK_ID.
Usage Example:
What was the VALUE for PK_ID=1 on 2010-05-22?
It's easy to see that from 1999-06-06 to 2014-04-03 the VALUE=103 for PK_ID=1, but how to query for 2010-05-22 ?