Domanda

Sample Table

I'm looking for SQL which give me the job, present position, previous position, change date for last 30 days...

Much Appreciated.. Thanks

È stato utile?

Soluzione

Revised

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
)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a dba.stackexchange
scroll top