Oracle-10g

過去 30 天列中先前值的 SQL

  • September 16, 2020

樣品表

我正在尋找可以為我提供工作、目前職位、以前職位、過去 30 天更改日期的 SQL…

非常感謝..謝謝

修改

SELECT id, j1.position, j2.position, j1.change_date
FROM tb_job j1
JOIN tb_job j2
  on j2.id = j1.id
  and j2.change_date < j1.change_date
  and j2.change_date > (j1.change_date - INTERVAL '30' DAY)
WHERE not exists
(select * from tb_job j
where j.id = j1.id
and j.change_date < j1.change_date
and j.change_date > j2.change_date
)

引用自:https://dba.stackexchange.com/questions/275356