jeudi 21 avril 2016

SQLite3 select last event by user

I have the followinf table 'events'.

| id | event_type | by_user | asset |       time |
|  1 | owner      | a       |    10 | 1111111111 |
|  2 | updated    | b       |    20 | 1111111112 |
|  3 | owner      | a       |    30 | 1111111113 |
|  4 | owner      | c       |    20 | 1111111114 |
|  5 | updated    | a       |    10 | 1111111115 |
|  6 | owner      | a       |    20 | 1111111118 |

I would like to select the assets where user 'a' was the last user with an 'owner' event_type. So in this example the id's 1, 3 and 6 (the assets 10, 20 and 30 are owned by user 'a').

Aucun commentaire:

Enregistrer un commentaire