I have a table used for a chat. Among others there is a field called userid and a field called timesent. I need to know the latest timesent for each userid in the table, so that I can delete them from the table if they haven’t said anything for 3 minutes, in which case I will assume they are gone.
I can’t really crack this nut… How do I query.
I could of course split it up and first select all the userids and then loop through them and select top 1 timesent in my method, but I was wondering if sql alone can do the trick, so I don’t need to execute tons of queries.
To get the latest
timesentperuseridyou can useMAXOr to do the specified
deleteyou can use