我在SQLite中有一个表:
CREATE TABLE test_results(timestamp TEXT, npass INTEGER, nfails INTEGER)
我想返回每天的最后一次通过/失败信息.例如,如果表包含...
2009-08-31 23:30:19|0|24 2009-08-31 23:37:18|0|24 2009-08-31 23:40:00|0|24 2009-09-01 19:02:13|0|2 2009-09-01 19:08:24|2|0 2009-09-01 19:20:29|2|0
我想要一个选择声明返回...
2009-08-31 23:40:00|0|24 2009-09-01 19:20:29|2|0
提前致谢!
尝试:
SELECT t.timestamp, t.npass, t.nfails FROM TEST_RESULTS t JOIN (SELECT MAX(tt.timestamp) 'maxtimestamp' FROM TEST_RESULTS tt GROUP BY date(tt.timestamp)) m ON m.maxtimestamp = t.timestamp