Fix error in fetching subtables when flattening report for range period.