• /
  • EnglishEspañol日本語한국어Português
  • Log inStart now

New NRQL subqueries for more powerful data exploration

July 6, 2022

Connect data across different sources in a single query

New Relic Query Language(NRQL) just got more powerful! With subqueries, you can now dive deeper to expand your analysis to include data from different data sources, time ranges, and entities in a single query.

A subquery is simply a NRQL query which is embedded inside of another query. Each subquery is evaluated, then the result is used during the execution of the outer query.

NRQL subquery examples

Here are two examples. For more details on how to use subqueries, see the examples in the docs.

Example #1

This query finds the number of transactions whose duration is above average:

SELECT count(*) FROM Transaction WHERE duration > (SELECT average(duration) FROM Transaction)

Example #2

This query leverages multiple nested subqueries to find the unique accounts responsible for transactions whose duration was greater than the 99th percentile:

FROM Transaction SELECT uniques(accountId) WHERE guid IN
  (FROM Transaction SELECT uniques(guid) WHERE duration >
  (FROM Transaction SELECT percentile(duration, 99)))

Demo

See how it works in the following video:

Get started

Edit this doc
Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.