Suppose I am storing events
associated with users
in a table as follows (with dt
standing in for the timestamp of the event):
I'm not at a computer to write code for this answer, but here's how I would go about a RegEx-based solution in SQL Server:
This should ultimately provide you with the functionality in SQL Server that your original question requests, however, if you're analyzing a very large dataset, this could be quite slow and there may be better ways to accomplish what you're looking for.