I have a table that has a user id & timestamp, like the following.
[member id] [timestamp]
1 1142461087
1 1339461211
2 1321280124
1 1249042100
3 1308325002
3 1308259235
I want to return a list of unique member ids who have not logged in for 30 days or longer.
This is my current query:
SELECT member_id, login_timestamp
FROM logins
WHERE login_timestamp <= 1329461087
GROUP BY member_id
ORDER BY login_timestamp DESC
I thought this was correct, but for some reason, in production, the admin user's ID shows up on the list, which is not possible since admin logs every day.
Something like this should work.
SELECT member_id, MAX(login_timestamp)
FROM logins
GROUP BY member_id
HAVING MAX(login_timestamp) <= 1329461087
ORDER BY MAX(login_timestamp) DESC
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With