start_time , stop_time , userid 20020901101111 , 20021002121201 , fred 20020904102010 , NULL , johnwhoneverlogsoff #### select count(*) from sessions where start_time < $end_of_segment and (stop_time > $start_of_segment || stop_time IS NULL);