Listing 4: Query to Calculate the Desired Results, Solution 1 SELECT app, MAX(concurrent) AS mx FROM (SELECT timeslot, app, COUNT(*) AS concurrent FROM (SELECT timeslot, app FROM VTimeSlots AS TS JOIN Sessions AS S ON TS.timeslot >= S.starttime AND TS.timeslot < S.endtime) AS TSAPP GROUP BY timeslot, app) AS C GROUP BY app