Florian Schricker <fschric...@gmail.com> wrote: > Schema of DB (simplified): > - Oper (string) > - Product (string) > - Category (string) > - Name (string) > - CreateTS (Timestamp) > - Value (Double) > > Primary keys are Oper, Product, Category, Name and CreateTS > > What I could not figure out: Suppose I want to select rows by "op", > "cat", "product" and get all measurements "m1" to "m4" with the latest > timestamp in CreateTS. > > So for a set of measurements identified by everything but their name > select the latest rows as defined by the timestamp.
select * from mytable t1 where oper=:oper and product=:product and category=:category and createTs = (select max(createTs) from mytable t2 where t1.oper = t2.oper and t1.product = t2.product and t1.category = t2.category and t1.name = t2.name ); Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users