All Products
Search
Document Center

Time Series Database:Merge Operations

Last Updated:Aug 05, 2020

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.

  1. > SELECT MEAN("water_level") FROM "h2o_feet"
  2. name: h2o_feet
  3. --------------
  4. time mean
  5. 1970-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.

  1. > SELECT MEAN("water_level") FROM "h2o_feet" WHERE "location" = 'coyote_creek'
  2. name: h2o_feet
  3. --------------
  4. time mean
  5. 1970-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.

  1. > SELECT MEAN("water_level") FROM "h2o_feet" GROUP BY "location"
  2. name: h2o_feet
  3. tags: location=coyote_creek
  4. time mean
  5. ---- ----
  6. 1970-01-01T00:00:00Z 5.359342451341401
  7. name: h2o_feet
  8. tags: location=santa_monica
  9. time mean
  10. ---- ----
  11. 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®.