SELECT datetime(Table1.stamp), Table1.value, Table2.value FROM (SELECT Table1.stamp AS stamp1, max(Table2.stamp) AS stamp2 FROM Table1 LEFT JOIN Table2 ON Table1.stamp >= Table2.stamp GROUP BY Table1.stamp) LEFT JOIN Table1 ON Table1.stamp = stamp1 LEFT JOIN Table2 ON Table2.stamp = stamp2;