Reputation: 111
I have a table with price info. And building a front-end functionality that allows the user to see all prices from the last X minutes, where user specifies X.
How do I query this in q?
Upvotes: 0
Views: 884
Reputation: 611
Let's say your table is called table
. You could create a function f
which takes one argument x
:the number of minutes previously you want to select from.
q)f:{select price from table where time within (.z.p-`minute$x;.z.p)}
Then, for example to get price info from the last 15 minutes you would do:
q)f[15]
Upvotes: 5
Reputation: 126
Assuming your table is named trades
, and the trades
table has a time column you can use the following function to achieve the desired output:
q){select from trades where time >= .z.n-`minute$x}
Upvotes: 5