select (Select count(*) as usercount from radius.userlogs force INDEX (enddatetime) where startdatetime <= concat('2005-12-04 ', tt.mytime) and enddatetime >= date_add(concat('2005-12-04 ', tt.mytime) , INTERVAL 1 MINUTE) and nasclient like '65.111.192.%' ) as usercount, mytime from timetable as tt order by mytime asc