Drop rows identified within moving time window
问题 I have a dataset of hospitalisations ('spells') - 1 row per spell. I want to drop any spells recorded within a week after another (there could be multiple) - the rationale being is that they're likely symptomatic of the same underlying cause. Here is some play data: create table hif_user.rzb_recurse_src ( patid integer not null, eventdate integer not null, type smallint not null ); insert into hif_user.rzb_recurse_src values (1,1,1); insert into hif_user.rzb_recurse_src values (1,3,2); insert