There is a table:
event | id | timestamp
---------------------
event1 | 001 | 21-03-15
event2 | 001 | 22-03-15
event1 | 002 | 23-03-15
event2 | 002 | 24-03-15
What should be the query to display the result:
id | event1 | event2 |
----------------------
001 | 21-03-15 | 22-03-15 |
002 | 23-03-15 | 24-03-15 |
It seems to me that you first need to make a choice unique id:
SELECT id FROM test GROUP BY id;
And here is something like this:
SELECT timestamp
FROM ...
WHERE id IN (SELECT id FROM test GROUP BY id) AND event='event1';
Events are known in advance ('event1', 'event2'). If there are repeated events under the same id, with a different or the same timestamp, add columns to the result, for example:
id | event1 | event2 | event1 | event2 |
----------------------------------------
001 | 21-03-15 | 22-03-15 | 23-03-15 | 23-03-15 |
002 | 23-03-15 | 24-03-15 | NULL | NULL |