I would appreciate if someone could help me with this simple query I am struggling with:
I have a table holding the following:
1) Running_ID - unsigned int (auto increment)
1) User_ID - unsigned int
2) Action - varchar(255)
3) Time_Of_Action - datetime
Possible actions are: install and uninstall
Every time a user performs an action, a record is added to the table.
So a user could have: install, then uninstall, then install again, and so on
What I need is a query that will prepare a dump of User_ID and Time_Of_Action for users whose last action was 'uninstall'
If a user only installed, or installed, uninstalled and then installed again, I don't want him.
Any help would be appreciated
FROM ( SELECT User_ID
, MAX(Time_Of_Action) AS last_action
BY User_ID ) AS m
JOIN daTable AS t
ON t.User_ID = m.User_ID
AND t.Time_Of_Action = m.last_action
AND t.Action = 'uninstall'
I see how you solved the problem