I am using DB2 in this case, but I'm figuring this has a generic SQL answer. I have simplified the data as much as I can. I am counting actions on things called "Claims". Each claim has a unique claim number. Each action is timestamped in the format "hhmm". Actually, I'm not counting actions, I'm counting action sessions--Most of the time, a person performs one action on one claim, and that's one action session. But sometimes a person performs multiple actions on one claim, separated by a few seconds or a few minutes: that also would be one action session. But if somebody performed an action on a claim at 10am, and then performed an action on that same claim at 1pm, those would be two action sessions. For my purposes, the time window for what makes something one action session vs. two action sessions is 3 hours, but that's arbitrary, of course. And there is no worry of the window spanning across midnight. Also, I have read-only access to this data, and I have to do this in one statement. Thanks.I am using DB2 in this case, but I'm figuring t