WEB LISTING 2: Query That Returns Session Groups' Start and End Times SELECT DISTINCT username, starttime, (SELECT MIN(endtime) FROM Sessions AS S3 WHERE S3.username = S1.username AND S3.endtime >= S1.starttime AND ISNULL( (SELECT MIN(starttime) FROM Sessions AS S4 WHERE S4.username = S1.username AND S4.endtime > S3.endtime), S3.endtime + 1) > S3.endtime) AS endtime FROM Sessions AS S1 WHERE ISNULL( (SELECT MAX(endtime) FROM Sessions AS S2 WHERE S2.username = S1.username AND S2.starttime < S1.starttime), S1.starttime -1) < S1.starttime