Skip to content

Commit

Permalink
Merge pull request #6854 from mlobiondo-newrelic/mlobiondo/document-a…
Browse files Browse the repository at this point in the history
…ccountid-function

AccountId() NRQL function (not yet ready for publish)
  • Loading branch information
zuluecho9 committed Apr 5, 2022
2 parents cb82029 + 8c02c77 commit abd75da
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1863,6 +1863,42 @@ SELECT histogram(duration, 10, 20) FROM PageView SINCE 1 week ago
Use non-aggregator functions for non-numerical data in NRQL queries.

<CollapserGroup>
<Collapser
className="freq-link"
title={<InlineCode>accountId()</InlineCode>}
>
Use the `accountId()` function to return the [account ID](/docs/accounts/accounts-billing/account-structure/account-id) associated with queried data. This function takes no arguments. Here are some example queries:

<CollapserGroup>
<Collapser title="Get the account ID for each Transaction event">
This query returns the account ID associated with each `Transaction` event returned:

```
SELECT accountId() FROM Transaction SINCE 1 day ago
```
</Collapser>
</CollapserGroup>

<CollapserGroup>
<Collapser title="Get the count of Transaction events for each account">
This query returns the number of `Transaction` events in the last day that are associated with each account ID:

```
SELECT count(*) FROM Transaction FACET accountId() SINCE 1 day ago
```
</Collapser>
</CollapserGroup>

<CollapserGroup>
<Collapser title="Get the count of Transaction events for each account specified in WHERE clause">
This query returns the number of `Transaction` events in the last day where the account ID is specifically one of `1`, `2`, or `3`:

```
SELECT count(*) FROM Transaction WHERE accountId() IN (1,2,3) SINCE 1 day ago
```
</Collapser>
</CollapserGroup>
</Collapser>
<Collapser
className="freq-link"
title={<InlineCode>earliest(attribute)</InlineCode>}
Expand Down

0 comments on commit abd75da

Please sign in to comment.