fixed crash when sql statement returns no rows for a time frame.