Given the following table:
time | col1 col2 col3 ...
--------------------------------
10:53:02 | 89 89 76 ...
...
How does one select a subset of columns from this table (including the index) referenced by a list of column names i.e. cols:('col1';'col3');
Whereby the expected result would be:
time | col1 col3
----------------------
10:53:02 | 89 89
...
Thanks
You could use a take (#) keyword with the each right (/:) adverb. So q will take the subset of sym and price columns from the table t and return a table with your key and your required subset of data
q)t:([time:.z.z+ 1 2];sym:`a`b;price:10 20;vol:30 40)
q)c:`sym`price
q)c#/:t
time | sym price
-----------------------| ---------
2019.09.05T07:56:36.069| a 10
2019.09.06T07:56:36.069| b 20
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With