Documentation

Find and count unique values

These examples use NOAA water sample data.

The following examples identify and count unique locations that data was collected from.

Find unique values

This query:

  • Uses group() to ungroup data and return results in a single table.
  • Uses keep() and unique() to return unique values in the specified column.

    from(bucket: "noaa")
    |> group()
    |> keep(columns: ["location"])
    |> unique(column: "location")
    

Example results

location
coyote_creek
santa_monica

Count unique values

This query:

  • Uses group() to ungroup data and return results in a single table.
  • Uses keep(), unique(), and then count() to count the number of unique values.

    from(bucket: "noaa")
    |> group()
    |> unique(column: "location")
    |> count(column: "location")
    

Example results

location
2

New! Cloud or OSS?

InfluxDB OSS 2.0 now generally available!

InfluxDB OSS 2.0 is now generally available and ready for production use. See the InfluxDB OSS 2.0 release notes.

For information about upgrading to InfluxDB OSS 2.0, see: