From cf8d2a0d3d8a2672be72348541e4f2797c18e2e3 Mon Sep 17 00:00:00 2001 From: Sunbrye Ly Date: Mon, 31 Oct 2022 15:17:21 -0700 Subject: [PATCH] feat: add to v2.3 --- .../influxdb/v2.3/query-data/flux/sort-limit.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/content/influxdb/v2.3/query-data/flux/sort-limit.md b/content/influxdb/v2.3/query-data/flux/sort-limit.md index 591fbfea1..ae2396887 100644 --- a/content/influxdb/v2.3/query-data/flux/sort-limit.md +++ b/content/influxdb/v2.3/query-data/flux/sort-limit.md @@ -18,6 +18,8 @@ related: - /{{< latest "flux" >}}/stdlib/universe/limit list_query_example: sort_limit --- +- [Sort and Limit](#sort-and-limit) +- [Tail](#tail) Use [`sort()`](/{{< latest "flux" >}}/stdlib/universe/sort) to order records within each table by specific columns and @@ -66,3 +68,17 @@ You now have created a Flux query that sorts and limits data. Flux also provides the [`top()`](/{{< latest "flux" >}}/stdlib/universe/top) and [`bottom()`](/{{< latest "flux" >}}/stdlib/universe/bottom) functions to perform both of these functions at the same time. + +## Tail +Use [`tail()`](/{{< latest "flux" >}}/stdlib/universe/tail/) +to limit the number of records in each output table to the last `n` rows. + +##### Example retrieving last 100 records +The following example retrieves the last 100 records within a given timerange. + +```js +from(bucket: "example-bucket") + |> range(start: -12h) + |> tail(n: 100) +``` +For additional examples, please see [tail() examples](/{{< latest "flux" >}}/stdlib/universe/tail/#examples).