• /
  • ログイン

Nested aggregation: make ordered computations in a single query

With nested aggregation, you can complete a NRQL query then make additional computations using the results of that query. Nested aggregation provides NRQL capabilities similar to the class of SQL subqueries or subselects where the subquery is in the FROM clause of the outer query.

Answer complex questions with a single query

Nested aggregation can help you to answer questions like these without building multiple queries:

  • Can I count the requests per minute for my application, then get the maximum requests per minute for the last hour?
  • Can I compute the average CPU usage of all my servers, and list only the ones with usage over 90%?
  • From all my user sessions, can I figure out what percentage bounced immediately?

Nested aggregation query structure and clauses

Every NRQL query must begin with a SELECT statement or a FROM clause. A nested aggregation query uses both a SELECT statement and a FROM clause and applies them to a whole query or queries contained within parentheses.

A complete and properly formatted nested aggregation query will look something like this:

SELECT function(attribute)
FROM (
SELECT function(attribute)
FROM dataType
WHERE attribute
TIMESERIES integer units
)

A few other details about query and clause behavior:

  • Nested queries can be more than two levels.
  • Both TIMESERIES and FACET can be applied to any part of the nested query, and don’t need to be identical at all levels.
  • SINCE, UNTIL, and COMPARE WITH clauses apply to the entire query and can only be used at the outermost level.

Nested aggregation query examples

Here are some examples of nested queries.

その他のヘルプ

さらに支援が必要な場合は、これらのサポートと学習リソースを確認してください:

問題を作成するこのページを編集する
Copyright © 2020 New Relic Inc.