LISTING 2: Query That Returns Session Groups' Start Times, Second Try SELECT DISTINCT username, starttime FROM Sessions AS S1 WHERE ISNULL( (SELECT MAX(endtime) FROM Sessions AS S2 WHERE S2.username = S1.username AND S2.starttime < S1.starttime), starttime -1) < starttime