2022.09.08 08:21 PM
Hi,
in the select statement, we can easily do 5 xbar time.minute to group the data for every 5 minutes, what is the equivalent for doing like every 5 millisecond?
2022.09.08 08:54 PM
If you don't cast to minutes first, you can explicitly group by millisecond (assuming your time column is a timestamp):
q)t:([]time:.z.p+500000*til 20;col:til 20)
q)select avg col by 5000000 xbar time from t // millisecond = 1000000 nanoseconds
time | col
-----------------------------| ----
2022.09.09D03:50:38.425000000| 2.5
2022.09.09D03:50:38.430000000| 10.5
2022.09.09D03:50:38.435000000| 17.5
2022.09.09 12:42 AM
A timespan can be used directly
q)select avg col by 0D00:00:00.005 xbar time from t
time | col
-----------------------------| ----
2022.09.09D07:40:23.110000000| 3
2022.09.09D07:40:23.115000000| 11.5
2022.09.09D07:40:23.120000000| 18
2022.09.10 09:32 PM
5 xbar `time$time
EMEA
Tel: +44 (0)28 3025 2242
AMERICAS
Tel: +1 (212) 447 6700
APAC
Tel: +61 (0)2 9236 5700
KX. All Rights Reserved.
KX and kdb+ are registered trademarks of KX Systems, Inc., a subsidiary of FD Technologies plc.