@Test
  public void minByTest() {
    String[] retArray = new String[] {"500", "500", "500"};
    try (Connection connection = EnvFactory.getEnv().getConnection();
        Statement statement = connection.createStatement()) {

      int cnt;
      try (ResultSet resultSet =
          statement.executeQuery(
              "SELECT min_by(time, s0) "
                  + "FROM root.vehicle.d0 WHERE time >= 100 AND time < 9000")) {
        cnt = 0;
        while (resultSet.next()) {
          String ans = resultSet.getString(minBy("Time", d0s0));
          Assert.assertEquals(retArray[cnt], ans);
          cnt++;
        }
        Assert.assertEquals(1, cnt);
      }

      try (ResultSet resultSet =
          statement.executeQuery("SELECT min_by(time,s0) FROM root.vehicle.d0 WHERE time < 2500")) {
        while (resultSet.next()) {
          String ans = resultSet.getString(minBy("Time", d0s0));
          Assert.assertEquals(retArray[cnt], ans);
          cnt++;
        }
        Assert.assertEquals(2, cnt);
      }

      // keep the correctness of `order by time desc`
      cnt = 0;
      try (ResultSet resultSet =
          statement.executeQuery(
              "SELECT min_by(time,s0) FROM root.vehicle.d0 WHERE time >= 100 AND time < 9000 order by time desc")) {
        while (resultSet.next()) {
          String ans = resultSet.getString(minBy("Time", d0s0));
          Assert.assertEquals(retArray[cnt], ans);
          cnt++;
        }
        Assert.assertEquals(1, cnt);
      }
    } catch (Exception e) {
      e.printStackTrace();
      fail(e.getMessage());
    }
  }
test aggregation query with more than one functions on one series
integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/IoTDBAggregationIT.java