GROUP BY <field> is not valid for InfluxDB 0.9+. You must group by tags.
Conversely, tags are not valid for functions. You must pass fields to a function. If you need "LAST(EnvURLPrefix)" and also "GROUP BY EnvURLPrefix" you will need to store it as both a field and a tag. I recommend using different identifiers, but you can overload the column name if you wish: https://docs.influxdata.com/influxdb/v1.0/query_language/data_exploration/# data-types-and-cast-operations-in-queries On Wed, Aug 24, 2016 at 9:43 AM, <[email protected]> wrote: > Hi! Let me first say that unfortunately I'm stuck on InfluxDB V0.11 for > now. We are planning to upgrade before long, but until then we have a > problem to solve. > > Consider these queries and results. I want it to group by both time and a > certain field. It doesn't seem to want to do that: > > *** Here's the flat data: > *** > > select StatusCode, EnvURLPrefix from "mydata" where EnvURLPrefix<>'' and > time>'2016-08-24T00:00:00Z' order by time asc > > name: mydata > ------------------------------------------------ > time StatusCode EnvURLPrefix > 1472040572816643085 200 custcloud > 1472040582523355782 200 custcloud > 1472040584623525061 200 custcloud > 1472049581236031421 200 custcloud > 1472052636389556409 200 custsurl > 1472052644355690414 200 custsurl > 1472052648011853447 200 custsurl > 1472052651224695399 200 custsurl > 1472052763520811540 200 custcloud > 1472052765026985777 200 custcloud > 1472052810615351717 200 custcloud > > *** Here's the group by: > *** > > select count(StatusCode), last(EnvURLPrefix) from "mydata" where > EnvURLPrefix<>'' and time>'2016-08-24T00:00:00Z' group by time(10m), > EnvURLPrefix fill(none) order by time asc > name: mydata > ------------------------------------------------ > time count last > 1472040000000000000 3 custcloud > 1472049000000000000 1 custcloud > 1472052600000000000 7 custcloud > > *** > It doesn't seem like the last function (or first function) does what I'm > hoping for. > > This is the result I really want to see: > > name: mydata > ------------------------------------------------ > time count last > 1472040000000000000 3 custcloud > 1472049000000000000 1 custcloud > 1472052600000000000 4 custsurl > 1472052600000000000 3 custcloud > > -- > Remember to include the InfluxDB version number with all issue reports > --- > You received this message because you are subscribed to the Google Groups > "InfluxDB" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/influxdb. > To view this discussion on the web visit https://groups.google.com/d/ms > gid/influxdb/0d7e3f4e-08b3-4bd1-88d8-8cfa51ca8f23%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Sean Beckett Director of Support and Professional Services InfluxDB -- Remember to include the InfluxDB version number with all issue reports --- You received this message because you are subscribed to the Google Groups "InfluxDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/influxdb. To view this discussion on the web visit https://groups.google.com/d/msgid/influxdb/CALGqCvPMs0SG76R3tUgJ2L92HkD3y0VqYZEP5%3D2ETbu4TaD%3DDw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
