I have a table of data with the following fields
EventID : Int, AutoIncrement, Primary Key
EventType : Int ' Defines what happened
EventTimeStamp : DateTime ' When the Event Happened
UserID : Int ' Unique
The query needs to tell me how many events occurred with new UserIDs for each day in the whole set. So, for each day, how many events exist which have a UserID which doesn't exist in any prior day. I've tried lots, and I can get unique users per day, but can't work out how to get 'NEW' users per day.
First get a table
b
with for each user when he first arrived, then join that table to get all events for that user for that day.Thank you all for your help - I've voted up the assistance. Here's what I did:
I created these 2 views (I needed to end up with a view, and had to create 2 as it seems you can't nest select statements within views).
Sightings:
NewUsers:
Good question. I don't have an exact solution but here's the approach I've seen before:
Do a SELECT where you compare the
EventTimeStamp
withMIN(EventTimeStamp)
for a given userID, as determined by a nested SELECT statement on the same table to calculate the MIN timestamp for each ID (e.g.GROUP BY UserID
).86400-(EventTimeStamp) as new_users