From f6434fa2acee7506deb003da498418459f6d5f5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Budzy=C5=84ski?= <37701616+pbudzyns@users.noreply.github.com> Date: Fri, 29 Apr 2022 19:23:37 +0200 Subject: [PATCH] Update on operate-on-columns.md (#3874) Add fixed date in `range()` to ensure the query returns data. Select `location` column before `group()` to avoid error since different tables report `_value` in different types. Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> Co-authored-by: Scott Anderson --- .../query-data/common-queries/operate-on-columns.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/content/influxdb/v2.1/query-data/common-queries/operate-on-columns.md b/content/influxdb/v2.1/query-data/common-queries/operate-on-columns.md index 520048eca..5e3437e9d 100644 --- a/content/influxdb/v2.1/query-data/common-queries/operate-on-columns.md +++ b/content/influxdb/v2.1/query-data/common-queries/operate-on-columns.md @@ -38,9 +38,9 @@ This query: ```js from(bucket: "noaa") - |> range(start: -30d) - |> group() + |> range(start: 2019-08-17) |> keep(columns: ["location"]) + |> group() |> unique(column: "location") ``` @@ -59,6 +59,8 @@ This query: ```js from(bucket: "noaa") + |> range(start: 2019-08-17) + |> keep(columns: ["location"]) |> group() |> unique(column: "location") |> count(column: "location") @@ -83,8 +85,8 @@ The following query: ```js from(bucket: "noaa") + |> range(start: 2019-08-17) |> filter(fn: (r) => r._measurement == "average_temperature") - |> range(start: -30d) |> map(fn: (r) => ({r with _value: (float(v: r._value) - 32.0) * 5.0 / 9.0} )) ``` @@ -115,8 +117,8 @@ The following query: ```js from(bucket: "noaa") + |> range(start: 2019-08-17) |> filter(fn: (r) => r._measurement == "average_temperature") - |> range(start: -30d) |> map(fn: (r) => ({r with celsius: (r._value - 32.0) * 5.0 / 9.0})) ```