On 11/22/2012 4:47 PM, Steffen Mangold wrote:
HI sqlite community,

I have a problem I get stucked, maybe someone can help me. :(

My issue:

For instance if we have 10 rows with following data

ID      | TimeStamp             | Status
----------------------------------------------------
0       | 2012-07-24 22:23:00   | status1
1       | 2012-07-24 22:23:05   | status1
2       | 2012-07-24 22:23:10   | status2
3       | 2012-07-24 22:23:16   | status2
4       | 2012-07-24 22:23:21   | status2
5       | 2012-07-24 22:23:26   | status2
6       | 2012-07-24 22:23:32   | status2
7       | 2012-07-24 22:23:37   | status3
8       | 2012-07-24 22:23:42   | status3
9       | 2012-07-24 22:23:47   | status3

What I want as result is
ID      | Begin                 | End                   | Status
-------------------------------------------------------------------------------
0       | 2012-07-24 22:23:00   | 2012-07-24 22:23:05   | status1
1       | 2012-07-24 22:23:10   | 2012-07-24 22:23:32   | status2
2       | 2012-07-24 22:23:37   | 2012-07-24 22:23:47   | status3


Hmmm, the ID in the result bears virtually no relation to the ID in the data. Is that intentional?

Anyhow, some of what you want could come from

select min(TimeStamp) as Begin, max(TimeStamp) as End, Status from Data group by Status order by Status


HTH,

Gerry


_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to