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 |