我在SQLite中有一张表
/* Create a table called NAMES */
CREATE TABLE EVENTS(Id integer , Eventtype integer,value integer,Timestamp DATETIME);
/* Create few records in this table */
INSERT INTO EVENTS VALUES(1,2,1,'2009-01-01 10:00:00'); --ROW1
INSERT INTO EVENTS VALUES(1,2,2,'2007-01-01 10:00:00'); --ROW2
INSERT INTO EVENTS VALUES(2,2,3,'2008-01-01 10:00:00’); --ROW3
查询所需的是ROW1和ROW3。该查询应基于时间戳选择最新的重复ID和Eventtype组合。 ROW1和ROW2具有相同的事件类型和ID,但ROW1是最新的,因此应选择它。