sql server - How to find records that are more than 5 mins after the record before it in sql -


given table "recorded" date time field.

how can select records have recorded date/time more 5 mins after record before when table sorted recorded. or put way, gaps between records greater 5 min.

at moment doing in c# iterating on set , comparing record n record n+ 1.

is possible sql, preferably out using cursor?

how cte approach.

with mrows (      select  *, row_number() on (order recorded) rn         table_name )   select *    mrows mr1 inner join mrows mr2 on     mr1.rn = mr2.rn - 1  datediff(mm, mr1.recorded, mr2.recorded) = 5; 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -