To keep it simple, my question is similar to THIS QUESTION, PART 2, only problem is, I am not running Oracle and thus can not use the rownumbers.
For those who need more information and examples:
I have a table
contractId date value 1 09/02/2011 A 1 13/02/2011 C 2 02/02/2011 D 2 08/02/2011 A 2 12/02/2011 C 3 22/01/2011 C 3 30/01/2011 B 3 12/02/2011 D 3 21/01/2011 A
EDIT: added another line for ContractID. Since I had some code myself, but that would display the following:
contractId date value value_old 1 09/02/2011 A 2 08/02/2011 A D 3 30/01/2011 B C 3 30/01/2011 B A
But that is not what I want ! The result should still be as below!
Now I want to select the last record before a given date and compare that with the previous value.
Suppose the ‘given date’ is 11/02/2011 in this example, the output should be like this:
contractId date value value_old 1 09/02/2011 A 2 08/02/2011 A D 3 30/01/2011 B C
I do have the query to select the last record before the given date. That is the easy part. But to select the last record before that, I am lost…
I really hope I can get some help here, have been breaking my head over this for days and looking for answers on the web and stackoverflow.
One possibility: