5

How can I use the xbar function to aggregate rows in a table in 10 microsecond bars. The table consists of the columns timestamp and val. For aggregating in millisecond bars instead I already know that I can simply use timestamp.datetime in the xbar query.

A possible result table should look as follows:

timestamp                 | val
--------------------------| ---
2015.12.02D12:19:44.434430| 2
2015.12.02D12:19:44.434440| 8
2015.12.02D12:19:44.434450| 5

Any help is appreciated.

user1056903
  • 921
  • 9
  • 26

1 Answers1

3

The below should work:

d:([]t:asc .z.P+100*10?100;v:10?10)
select avg v by (10*1000) xbar t from d

Note that the output time column is still a 'timestamp' ("p") type, however the values are barred in microseconds.

I wrote the first xbar argument as (10*1000) for clarity. To change to 5 microseconds you can do (5*1000) etc.

jgleeson
  • 955
  • 5
  • 11
  • 4
    May be more convenient to use `timespan` on LHS of `xbar` - example: `select avg v by 0D00:00:00.01 xbar t from d` - which will give you 10ms buckets. – MdSalih Dec 02 '15 at 22:48