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()
andunique()
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 thencount()
to count the number of unique values.
from(bucket: "noaa")
|> group()
|> unique(column: "location")
|> count(column: "location")
Example results
location |
---|
2 |
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for InfluxDB and this documentation. To find support, the following resources are available:
InfluxDB Cloud and InfluxDB Enterprise customers can contact InfluxData Support.