influxdata / influxdata/influxdb

Err: mixing aggregate and non-aggregate queries is not supported

Open
#23,243 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

I’m trying to subtract the mean from a column in InfluxQL 1.7.

```
> select col - mean(col) from sensor -- Err: mixing aggregate and non-aggregate queries is not supported

> select col - 2 from sensor -- works fine

> select col - meanC from (select col from sensor),(select mean(col) as meanC from sensor)
time value_meanV
---- -----------
2019-03-02T14:19:34.000000001Z
2019-03-02T14:19:40Z
2019-03-02T14:19:50Z
2019-03-02T14:20:00Z
2019-03-02T14:20:10Z
2019-03-02T14:20:20Z
2019-03-02T14:20:30Z
```

The last query is giving wrong results. I think it could be because of the join type.

How could one perform a column operation using an aggregation value in InfluxDB?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reported InfluxQL queries, especially the aggregate and non-aggregate expression and the subquery operation, using the examples in the issue. Compare the returned values with the expected column calculation; the issue does not name a source file, test, or a specific implementation change, so the desired behavior needs clarification before work can begin.

Written by the indexing model from the issue text.

Assessment

Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.