@Test
  public void multipleScopesShouldBeAllowedAtSameLevelOfNesting() throws Exception {
    // Task ID: NQIU 9
    CacheUtils.getQueryService();
    String queries =
        "select distinct p.x from (select distinct x, pos from " + SEPARATOR
            + "pos x, x.positions.values pos) p, (select distinct * from " + SEPARATOR + "pos"
            + SEPARATOR + "positions rtPos where rtPos.secId = p.pos.secId)";
    Region r = CacheUtils.getRegion(SEPARATOR + "pos");
    Region r1 = r.createSubregion("positions", new AttributesFactory().createRegionAttributes());


    r1.put("1", new Position("SUN", 2.272));
    r1.put("2", new Position("IBM", 2.272));
    r1.put("3", new Position("YHOO", 2.272));
    r1.put("4", new Position("GOOG", 2.272));
    r1.put("5", new Position("MSFT", 2.272));
    Query q = CacheUtils.getQueryService().newQuery(queries);
    CacheUtils.getLogger().info("Executing query: " + queries);
    SelectResults rs = (SelectResults) q.execute();
    assertTrue("Resultset size should be > 0", rs.size() > 0);
  }
TRAC #36659: Nested query failure due to incorrect scope resolution
geode-core/src/integrationTest/java/org/apache/geode/cache/query/QueryServiceRegressionTest.java