Partitioning value for sub-queries