Join two tables where table A has a date value and needs to find the next date in B below the date in A
I got this table "A": | id | date | =================== | 1 | 2010-01-13 | | 2 | 2011-04-19 | | 3 | 2011-05-07 | | .. | ... | and this table "B": | date | value | ====================== | 2009-03-29 | 0.5 | | 2010-01-30 | 0.55 | | 2011-08-12 | 0.67 | Now I am looking for a way to JOIN those two tables having the "value" column in "B" mapped to the dates in "A". The tricky part for me here is that table "B" only stores the change date and the new value. Now when I need this value in table "A" the SQL needs to look back what date is the next below the date it is asking the value for. So in the