Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add info about InfluxQL GROUP BY time() with time bounds behavior in subqueries #5269

Open
sanderson opened this issue Dec 13, 2023 · 0 comments

Comments

@sanderson
Copy link
Collaborator

If you use GROUP BY time() in a subquery and include time bounds in the WHERE clause, the WHERE clause has to be to be in the inner query before the GROUP BY clause, not the outer query. Otherwise the query returns no results.

For example, the following query doesn't return any results:

SELECT
  mean("price") AS "mean_price"
FROM
  (
    SELECT
      MEAN("price") AS "price"
    FROM
      "bitcoin".."coindesk"
    GROUP BY
      "code",
      time(1d)
  )
WHERE
  time >= '2023-01-01T00:00:00Z'
  AND time < '2023-02-01T00:00:00Z'

However, the following query does return results:

SELECT
  mean("price") AS "mean_price"
FROM
  (
    SELECT
      MEAN("price") AS "price"
    FROM
      "bitcoin".."coindesk"
    WHERE
      time > '2023-01-01T00:00:00Z'
      AND time < '2023-02-01T00:00:00Z'
    GROUP BY
      "code",
      time(1d)
  )
Relevant URLs
@sanderson sanderson changed the title Add info about InfluxQL GROUP BY with time bounds behavior in subqueries Add info about InfluxQL GROUP BY time() with time bounds behavior in subqueries Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant