In TSDB for InfluxDB®, queries automatically merge series.
Examples
The h2o_feet measurement in the NOAA_water_database database is included in each of the two series. The first series consists of the h2o_feet measurement and the location = coyote_creek tag. The second series consists of the h2o_feet measurement and the location = santa_monica tag.
The following query automatically merges the two series when the query calculates the average field value of the water_level field key.
> SELECT MEAN("water_level") FROM "h2o_feet"name: h2o_feet--------------time mean1970-01-01T00:00:00Z 4.442107025822521
If you want to obtain the average field value of the water_level field key for only the first series, set the value of the location tag key to coyote_creek in the WHERE clause.
> SELECT MEAN("water_level") FROM "h2o_feet" WHERE "location" = 'coyote_creek'name: h2o_feet--------------time mean1970-01-01T00:00:00Z 5.359342451341401
If you want to obtain the average field value of the water_level field key for each series, include a GROUP BY clause in your query.
> SELECT MEAN("water_level") FROM "h2o_feet" GROUP BY "location"name: h2o_feettags: location=coyote_creektime mean---- ----1970-01-01T00:00:00Z 5.359342451341401name: h2o_feettags: location=santa_monicatime mean---- ----1970-01-01T00:00:00Z 3.530863470081006
InfluxDB® is a trademark registered by InfluxData, which is not affiliated with, and does not endorse, TSDB for InfluxDB®.