'Extracting specific value from a table
I have the tabe:
As: 11 43 23 67 76
Bs: 87 38 70 8 10
syms:A`B where 4 4
AA:([] A:As;B:Bs)
1#select A from AA
I get the output
A
--
11
I would like to know how to just have the value returned instead of having the output to be a table? So, in this case, it would just return 11.
Solution 1:[1]
One of numerous ways to do this
q)AA[0]`A
11
to get last item
q)last[AA]`A
76
or both at once
q)(first;last)@\:AA`A
11 76
Solution 2:[2]
You want to use the exec keyword instead of select when you want column values as a list:
1#exec A from AA
Solution 3:[3]
Try using exec instead of select, which will return just the value in a list.
Note: If the query is in a hdb / on a partitioned db then you'll need to select first then exec.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | kylebonnes |
| Solution 3 | xxPJFxx |
