sql - How do I find gap in sqlite table? -


i have sqlite table timestamps in milliseconds primary key each row should 1 second or 1000 apart 1 another. data recorder goes out , there no data in table time. how can find gaps using sql statement? cursor based solution possible know.

table = pvt ts 1119636081000 1119636082000 1119636083000 1119636084000 1119636085000 ------gap------ 1119636090000 1119636091000 

this may work. assuming table name "tstamps",

select a.ts tstamps not exists    (select b.ts     tstamps b     b.ts = a.ts+1000) , exists    (select c.ts     tstamps c     c.ts = a.ts+2000) 

another way

select a.ts tstamps not exists    (select b.ts     tstamps b     b.ts = a.ts+1000) , a.ts <    (select max(c.ts)     tstamps c    ) 

using minus operator. not sure, of these queries better performance wise.

select ts+1000 pvt ts != (select max(ts) pvt) minus select ts pvt ts != (select min(ts) pvt) 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -