Multi-dimensional DISTINCT queries aren't valid yet in InfluxQL. You can GROUP BY multiple tags and then strip out any duplicates in post-processing:
SELECT COUNT(DISTINCT(userid)) from <measurement> WHERE time > now() - 1d GROUP BY building, username On Wed, Aug 31, 2016 at 9:56 AM, Alan Jackson <[email protected]> wrote: > Sorry, I should have expanded on the query. The query in its entirety is: > > SELECT COUNT(DISTINCT(userid)) from <measurement> WHERE time > now() - 1d > GROUP BY building > ^^ this works, however ... > > The uniqueness I want to be on two fields, so below does not work. I am > already grouping by a separate field of 'building' so your example does not > reflect the actual condition which I unfortunately truncated in the > original post. > > SELECT COUNT(DISTINCT(userid, username)) from <measurement> WHERE time > > now() - 1d GROUP BY building > ^^ this thorws error > > Thanks > > - > Alan Jackson > > On Wednesday, August 31, 2016 at 11:41:51 AM UTC-4, Sean Beckett wrote: >> >> https://docs.influxdata.com/influxdb/v0.13/query_language/fu >> nctions/#distinct >> >> What you want, most likely, is >> >> SELECT COUNT(DISTINCT(userid)) FROM...GROUP BY username >> >> On Wed, Aug 31, 2016 at 8:33 AM, <[email protected]> wrote: >> >>> Hello >>> >>> I am trying to create a distinct value on two fields similar to the way >>> this is handled in PostgreSQL. i.e. SELECT DISTINCT userid, username FROM >>> ... >>> >>> in InfluxDB DISTINCT does not appear to support multiple fields as the I >>> ge the following when running: SELECT COUNT(DISTINCT(userid,username)) >>> FROM ... >>> >>> ERR: error parsing query: count(distinct <field>) can only have one >>> argument >>> >>> Is there another approach to this that will yield the same results? TIA >>> >>> - >>> Alan Jackson >>> >>> -- >>> 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/e6c194b8-3cd9-4cc9-a355-f18dfc241f95%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/7e4dec03-e293-499a-9c18-dab9f90d195a%40googlegroups.com > <https://groups.google.com/d/msgid/influxdb/7e4dec03-e293-499a-9c18-dab9f90d195a%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > 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/CALGqCvOD0CRD5yxG2_4%2BYTwXgek1P%3DKjVRGygWOGcEgUCbAxxw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
