Skip to content

Instantly share code, notes, and snippets.

@farhaven
Created February 21, 2019 09:42
Show Gist options
  • Save farhaven/3df4092485a62a6ddb5a2a24a0e575d1 to your computer and use it in GitHub Desktop.
Save farhaven/3df4092485a62a6ddb5a2a24a0e575d1 to your computer and use it in GitHub Desktop.
CREATE TABLE events (id INTEGER PRIMARY KEY, timestamp INTEGER, machine STRING);
INSERT INTO events (timestamp, machine) VALUES (123, 'a');
INSERT INTO events (timestamp, machine) VALUES (234, 'a');
INSERT INTO events (timestamp, machine) VALUES (345, 'a');
INSERT INTO events (timestamp, machine) VALUES (456, 'a');
INSERT INTO events (timestamp, machine) VALUES (555, 'b');
INSERT INTO events (timestamp, machine) VALUES (444, 'b');
INSERT INTO events (timestamp, machine) VALUES (333, 'b');
INSERT INTO events (timestamp, machine) VALUES (222, 'b');
INSERT INTO events (timestamp, machine) VALUES (111, 'b');
INSERT INTO events (timestamp, machine) VALUES (900, 'c');
SELECT * FROM (SELECT * FROM events ORDER BY timestamp) GROUP BY machine;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment