@Test
  public void groupByLevelWithTimeIntervalTest() throws Exception {
    String[] retArray1 =
        new String[] {
          "null", "88.24", "105.5", "null", "null", "125.5",
        };
    String[] retArray2 =
        new String[] {
          "null,null,null,null",
          "null,100,null,88.24",
          "200,200,31.685,105.5",
          "300,null,46.77,null",
          "null,null,null,null",
          "null,500,null,125.5",
        };
    try (Connection connection = EnvFactory.getEnv().getConnection();
        Statement statement = connection.createStatement()) {

      int cnt = 0;
      try (ResultSet resultSet =
          statement.executeQuery(
              "select sum(temperature) from root.sg2.* GROUP BY ([0, 600), 100ms), level=1")) {
        while (resultSet.next()) {
          String ans = "" + resultSet.getString(sum("root.sg2.*.temperature"));
          Assert.assertEquals(retArray1[cnt], ans);
          cnt++;
        }
      }

      cnt = 0;
      try (ResultSet resultSet =
          statement.executeQuery(
              "select max_time(temperature), avg(temperature) from root.*.* GROUP BY ([0, 600), 100ms), level=1")) {
        while (resultSet.next()) {
          String ans =
              resultSet.getString(maxTime("root.sg1.*.temperature"))
                  + ","
                  + resultSet.getString(maxTime("root.sg2.*.temperature"))
                  + ","
                  + resultSet.getString(avg("root.sg1.*.temperature"))
                  + ","
                  + resultSet.getString(avg("root.sg2.*.temperature"));
          Assert.assertEquals(retArray2[cnt], ans);
          cnt++;
        }
      }
    }
  }
[root.sg.d1.temperature, root.sg.d2.temperature] with level = 2

<p>Result is [root.*.d1.temperature, root.*.d2.temperature]
integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/IoTDBAggregationByLevelIT.java