database - SQLite Row_Num/ID -
i have sqlite database i'm trying use data from, there multiple sensors writing database. , need join 1 row proceeding row calculate value difference time period. catch rowid field in database can't used join on anymore since there more sensors beginning write database.
in sql server easy use row_number , partition sensor. found topic: how use row_number in sqlite , implemented suggestion:
select id, value , (select count(*) data b a.id >= b.id , b.value='yes') cnt data a.value='yes'; it works slow. there simple i'm missing? i've tried join on time difference possibly, create view. @ wits end! ideas!
here sample data:
rowid - sensorid - time - value 1 2 1-1-2015 245 2 3 1-1-2015 4456 3 1 1-1-2015 52 4 2 2-1-2015 325 5 1 2-1-2015 76 6 3 2-1-2015 5154 i need join row 6 row 2 , row 3 row 5 , forth based on sensorid.
the subquery can sped index correct structure. in case, column equality comparison must come first, , 1 unequality, second:
create index xxx on mytable(sensorid, time);
Comments
Post a Comment