SQL Query to Join Two Tables Based Off Closest Timestamp

后端 未结 3 1956
眼角桃花
眼角桃花 2020-12-16 12:41

I have two tables in SQL and I need to be able to do a join based off of the timestamp in table B that is earlier than or equal to the timestamp in table A.

So, here

3条回答
  •  孤城傲影
    2020-12-16 13:22

    SELECT case.id, case.resolution, case.timestamp, class.value
      FROM closed_cases AS case
      LEFT JOIN classifications AS class 
      ON case.timestamp >= class.timestamp
      WHERE case.timestamp BETWEEN $1 AND $2;
    

提交回复
热议问题