I have a postgresql table which has events recorded by date/time. The table has the columns id, event and timestamp.
My output has to be something like this:
'Day', '1st Timers', '2nd Timers', '3rd Timers', '3+ Timers'
1st timers are all ids that have done the event for the first time. 2nd timers are all ids that have done the event for the second time. etc. etc.
Is this possible using a single SQL query?
edit: Sample data and output as per request
user_id date                event
1       09/03/15 14:08      opened
2      10/03/15 14:08       opened
1      11/03/15 14:08       opened
4      14/03/15 14:08       opened
1      15/03/15 14:08       opened
5      16/03/15 14:08       opened
1      17/03/15 14:08       opened
4      17/03/15 14:08       opened
6      18/03/15 14:08       opened
1      18/03/15 14:08       opened
6      18/03/15 14:08       other
Output (for event=opened)
date        1time   2times  3times  4times  5times
09/03/15    1       0       0       0       0
10/03/15    1       0       0       0       0
11/03/15    0       1       0       0       0
14/03/15    1       0       0       0       0
15/03/15    0       0       1       0       0
16/03/15    1       0       0       0       0
17/03/15    0       1       0       1       0
18/03/15    1       0       0       0       1
 
     
     
    