Expand rectangle query with time and average functions.