Querying data that has more than 1 field

Hello,

I’m using Influx OSS v2.7.1 to store data from sensors. I have design schema to have tags like id to reference each data point and 3 fields - result, phenomenonTime, and resultTime - which are string. So when I query the data I use group by id to group records that have same id into the same table. In the query result it has 1 field value per record (according to the attached picture), but I want all of the fields to be in 1 record.

So, my questions my questions are:

  1. Is there a way that I can query all fields I have in each data point into 1 record?
  2. If I want to group the data by id and do use pagination parameters, how can I do that?
    I have come up with flux query command below, trying to group data by id and limit the query result to 10 groups but the actual query result doesn’t limit to 10 groups.
from(bucket: "observation_str_5s")
	|> range(start: 2023-07-28T16:53:15.000Z, stop: 2023-08-02T16:53:15.000Z)
	|> filter(fn: (r) =>
	  r._measurement == "64ab8ab0add4a23c51ad2360"
	)
	|> group(columns: ["id"])
	|> limit(n: 10)

Thank you in advance for all assistance and suggestions.

Hi @siriya_s and welcome to the InfluxData forum.

Can you share a CSV of your data (including the id tag) as exported from Influx Data Explorer and post here?

Sure, the csv file below is the query result I got from running flux query mentioned above.
query_result.csv

Hi @siriya_s and sorry for the delay. I was not able to load in your data, but thought about your question some more…

Have you played around with the pivot function? That should put the 3 fields (phenomenonTime, result and resultTime) into one record.

Also, in your screenshot I do not see any tag called “id”. What are the possible id values?

1 Like

Hi @grant1,

Thanks for the suggestion. I haven’t tried the pivot function yet. I will give it a try to see if it can put three fields in one record like I want.

And for the possible id values, actually they are going to be string ObjectId, but for the mock data I just use number as shown in the picture below.