Skip to content

Instantly share code, notes, and snippets.

@saml
Created April 6, 2016 21:24
Show Gist options
  • Select an option

  • Save saml/4bde5c24aa29e5bc141abb5ab926d2cc to your computer and use it in GitHub Desktop.

Select an option

Save saml/4bde5c24aa29e5bc141abb5ab926d2cc to your computer and use it in GitHub Desktop.
sqlite> create table things(user text, girl text, action text, date datetime);
sqlite> insert into things values ('saml', 'jessica alba', 'married', datetime('now'));
sqlite> insert into things values ('saml', 'jessica alba', 'divorced', datetime('now'));
sqlite> insert into things values ('saml', 'sigourney weaver', 'married', datetime('now'));
sqlite> insert into things values ('saml', 'sigourney weaver', 'divorced', datetime('now'));
sqlite> insert into things values ('saml', 'jessica alba', 'married', datetime('now'));
sqlite> select user,girl,action,max(date) from things where user = 'saml' group by girl;
saml|jessica alba|married|2016-04-06 21:24:09
saml|sigourney weaver|divorced|2016-04-06 21:24:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment