I have a database in SQLITE (lets call it params) that stores a list of parameter changes and the times that they changed. ie:
key paramid time val --- ------- ---- --- 1 7 1.2 0 2 3 2.5 23 3 3 5.6 54 4 3 7.1 76 5 7 8.4 1 6 3 9.2 33 7 9 9.7 22 8 3 10.3 21
I would like to use a query to generate a table that includes every time one parameter changed along with the value of the other parameter when the first parameter changed and the time of the change. ie:
param3Val latestParam7Val time --------- --------------- ---- 23 0 2.5 54 0 5.6 76 0 7.1 33 1 9.2 21 1 10.3
Any ideas for doing this efficiently in SQL?
Thanks!
You could use:
Alternative with joins: