On a PostgreSQL Server i’ve a table like this below :
+------+------+------------------+
| Code | kind| timestamp |
+------+------+------------------+
| 1 | I | 16-05-2011 09:17 |
| 1 | O | 16-05-2011 09:47 |
| 2 | I | 16-05-2011 09:37 |
| 3 | I | 16-05-2011 11:26 |
| 3 | O | 16-05-2011 12:11 |
| 3 | I | 16-05-2011 13:23 |
+------+------+------------------+
This table represent IN and OUT of person in a pool with relative timestamp, and i want to know the person in the pool at a given moment.
Is there a way to retrieve The row of kind ‘I’ that not have a corresponding ‘O’ ?
can i do it with a single Query ?
The code represent the person code …
LEFT JOIN is one way to do it with
It should be doable with Not Exists as well