我想在不到72小时的时间内回到我的医院,例如:
id_People id_issue internation_in internation_out
444 456789 2014-01-01 2014-01-07
444 465465 2014-02-10 2014-02-12
444 789564 2014-02-13 2014-02-20
重复次数小于72 hs = 1
答案 0 :(得分:0)
如果我理解正确,你想测量某人离开然后返回的时间:
select t.*,
(case when internation_out + interval '72 hour' >
lag(internation_out) over (partition by id_people order by internaion_in)
then 'YES'
else 'NO'
end)
from table t;