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

select ... AS does not work as expected #5679

Closed
tokudan opened this issue Feb 13, 2016 · 3 comments
Closed

select ... AS does not work as expected #5679

tokudan opened this issue Feb 13, 2016 · 3 comments

Comments

@tokudan
Copy link

tokudan commented Feb 13, 2016

It took me a long time to figure out where the "sum" field came after I migrated data.
Right now I have a measurement that is stored in a field named "sum" (automatically generated by a CQ). I need to copy that data into a field named "value". the syntax "SELECT field AS whatever" does not work, it only seems to work when a function is involved.
My goal is to run the following query and have the field "sum" renamed to "value".

SELECT "sum" AS "value" INTO l1.connected_clients_by_region_sum FROM "default"."connected.clients.by.region" WHERE time >= '2016-02-07T05:00:00Z' AND time < '2016-02-07T06:00:00Z' GROUP BY * fill(none)

Influxdb version 0.9.6.1+dfsg1-4, I did not see any notice that this beheaviour changed in 0.10, so I assume it's still current.

> SELECT sum(value) AS "value" FROM freifunk.l1.connected_clients WHERE time >= '2016-02-13T13:58:00Z' AND time < '2016-02-13T13:59:00Z' GROUP BY time(1m), region fill(none)
name: connected_clients
tags: region=ffhh
time            value
----            -----
1455371880      2150


name: connected_clients
tags: region=ffpi
time            value
----            -----
1455371880      254

> SELECT "sum" AS "value" FROM "default"."connected.clients.by.region"  WHERE time >= '2016-02-07T05:00:00Z' AND time < '2016-02-07T06:00:00Z' GROUP BY * fill(none) LIMIT 5
name: connected.clients.by.region
tags: region=ffhh
time            sum
----            ---
1454821200      1116
1454821260      1115
1454821320      1140
1454821380      1148
1454821440      1162


name: connected.clients.by.region
tags: region=ffpi
time            sum
----            ---
1454821200      186
1454821260      186
1454821320      188
1454821380      187
1454821440      18
@tokudan
Copy link
Author

tokudan commented Feb 13, 2016

found a workaround:

SELECT mean("sum") AS "value" FROM "default"."connected.clients.by.region"  WHERE time >= '2016-02-07T05:00:00Z' AND time < '2016-02-07T06:00:00Z' GROUP BY time(1m), * fill(none) LIMIT 5
name: connected.clients.by.region

the GROUP BY time(1m) must be chosen to never aggregate two values... it depends on the data.

@zstyblik
Copy link

I'd say this is a duplicate of #5567

@jsternberg
Copy link
Contributor

It looks like this is fixed as of 0.11.

> insert cpu,host=server01 value=3
> insert cpu,host=server02 value=5
> select sum(value) as value from cpu group by *
name: cpu
tags: host=server01
time    value
----    -----
0       3

name: cpu
tags: host=server02
time    value
----    -----
0       5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants